我正在尝试从模板化的基类模拟一个子类,稍后将对其进行指定。但得到了错误
test.C: In constructor ‘myDeri<U>::myDeri()’:
test.C:30:16: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x [enabled by default]
test.C:35:5: error: expected ‘{’ before ‘~’ token
仅来自以下
#include <iostream>
using namespace std;
// Base class
template<typename U>
class myBase // base class to be derived
{
public:
myBase(){}
~myBase() {}
};
template<typename U>
class myDeri : public myBase<U> // as i know, this should be Template derived class, Template base class case
{
public:
myDeri() : myBase<U> {}
~myDeri() {}
};
int main()
{
return (0);
}
答案 0 :(得分:4)
你没有正确调用模板化的基础clase的构造函数
myDeri() : myBase<U> {}
应该是
myDeri() : myBase<U>() {}