Error while templating a subclass from a templated base class

I am trying to create a subclass template that will be specified later from a templated base class. But got an error

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

      

only from the following

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

      

+3


source to share


1 answer


You are calling the templated base constructor incorrectly

myDeri() : myBase<U> {}

      



it should be

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

      

+4


source







All Articles