错误:期望的类名在“{”之前

error: expected class-name before ‘{’

本文关键字:之前 期望 错误      更新时间:2023-10-16

这是我的代码,我只在标题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也不会,不能用来代替字符串。

那和你正在做的相符吗?