3

我正在尝试从模板化的基类模板化一个子类,稍后将指定该子类。但是出现错误

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

1 回答 1

4

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

myDeri() : myBase<U> {}

应该

myDeri() : myBase<U>() {}
于 2013-01-28T02:55:16.840 回答