我有一个抽象类:
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/