错误:期望的类名在“{”之前
error: expected class-name before ‘{’
这是我的代码,我只在标题word.h中包含字符串。我不明白问题出在哪里。
#ifndef WORD_H
#define WORD_H
#include <string>
class word : public string
{
private:
static string valid_ch;
public:
word() {}
word(const string&);
static word extract(const string&, size_type&);
};
#endif
用std::string
代替string
同样,std::string
不是多态的(没有接口和破坏的虚函数),所以word
也不会,不能用来代替字符串。
那和你正在做的相符吗?
相关文章:
- 如何确保C++函数在定义之前声明(如override关键字)
- 为什么在定义函数之前先声明它
- Arduino:for/while/if在void setup()或void loop()之前?——错误:之前需要不合格
- 程序在执行程序的其余部分之前退出
- 如何将模板转换为C++11之前的模板
- 期望')'之前';' token g++
- 错误:')'令牌强制转换问题之前期望的主表达式
- Typedef 期望在" "之前';'
- 错误:当通过P2P通道连接两个NodeContainers时,期望主表达式在ns3中的const之前
- 错误:':'令牌之前期望的初始化项
- c++ -错误:在'{'标记之前期望的类名
- c++在数字常量之前表示期望的标识符
- 编译错误:solution.c:20:5: Error:期望的标识符或'('在' {' token{之前
- QT 5.2.1编译错误;在'delete'之前期望的非限定id
- 在c++中期望主表达式在token之前
- Node.js c++绑定错误:'('标记之前期望的构造函数、析构函数或类型转换
- {token c++之前的期望类名
- GCC期望模板名在' < '标记错误之前
- 在{token之前期望的类名-非常简单
- 错误:期望的类名在“{”之前