c++ - { token c++ 之前的预期类名

标签 c++ class abstract

我有一个抽象类:

template<class tip>
class apsMatrica
{
    public:
    virtual int find_max( int k) = 0;
    virtual bool GaussElim (std::vector<tip> &b) = 0;
    virtual std::vector<tip> vracanje (const std::vector<tip>& b)  = 0;
    virtual std::vector<tip> sustav (std::vector<tip> b) = 0;

};

和新类:

template <class tip>
class Matrica : public apsMatrica
{
 //some code here
}

如果我不在定义类 Matrica 之后放置“:public apsMatrica”,那么代码就可以正常工作

template <class tip>
class Matrica 
{
 //some code here
}

否则它不起作用并且有错误:

 expected class-name before '{' token

我已将 .h 文件包含到 .cpp 文件中,我想知道可能是什么问题?

最佳答案

apsMatrica 是一个类模板,所以这样做:

class Matrica : public apsMatrica<tip> //or any other type

关于c++ - { token c++ 之前的预期类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23716908/

相关文章:

C++ 代码跳过 if 语句。不允许用户输入

c++ - 我可以在 QListWidget 的每个项目中存储一些用户数据吗?

c# - 我如何计算(手动)字符串的 SizeOf,以及一个类是否添加到一个大小?

Java抽象类通过声明新方法继承

c++ - 如何定义 qmake 的库搜索目录?

c++ - 如何定义一个函数来处理 move 语义和复制语义?

java - 访问嵌套类中的变量

c++ - 将字符串 append 到 C++ 中的类变量

java - 强制用户在 Java 中声明变量

java - 抽象类和多态性