mercredi 25 mars 2015

Can somebody please explain to me why I'm being stupid? I don't understand why I'm getting this error message:



template <class T> class Base
{
public:
int x ;
} ;

template <class T> class Derived : public Base<T>
{
public:
void f() { x = 99 ; } // error: 'x' was not declared in this scope
} ;


I have to do this to get it to compile:



void f() { Base<T>::x = 99 ; }


I am using g++ version 4.9.1 for MinGW, with std=c++11.


Aucun commentaire:

Enregistrer un commentaire