while in visual c++ the code below is accepted, g++ will generate the error:
“class Derived does not have any field name Base”
which is following the standard?
template <class T>
class Base
{
public:
Base(){};
};
template <class T>
class Derived:public Base<T>
{
public:
Derived():Base(){}
};
BTW: both accept
Derived():Base<T>(){}
so meantime, I will follow gcc
MSVC++ is not correct.
Baseis a template, not a type.Note that in the usual case,
Baseis looked up in the scope ofDerived<T>, which means that it will first find the injected class name inherited fromBase<T>, which refers to the typeBase<T>. But as you have a dependent base class, the name inherited fromBase<T>is not found (the base class scope is not looked into).