我正在尝试从一个模板化的基类中模板化一个子类,稍后再指定。但是有错误

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);
}

最佳答案

您没有正确调用模板化基本clase的构造函数

myDeri() : myBase<U> {}

应该
myDeri() : myBase<U>() {}

07-24 14:14