Here is code sample which reproduces my problem:
template <typename myType> class Base { public: Base() {} virtual ~Base() {} protected: int myOption; virtual void set() = 0; }; template <typename InterfaceType> class ChildClass : public Base < std::vector<InterfaceType> > { public: ChildClass() {} virtual ~ChildClass() {} protected: virtual void set(); }; template <typename InterfaceType> void ChildClass<InterfaceType>::set() { myOption = 10; } My usage in main():
ChildClass<int> myObject; I get the following error (gcc 4.4.3 on ubuntu):
‘myOption’ was not declared in this scope
If my ChildClass would be without new template parameter this would work fine, i.e.:
class ChildClass : public Base < std::vector<SomeConcreteType> > Edit
I've managed to solve it, if my set method looks like:
Base<std::vector<InterfaceType> >::myOption = 10; It works fine. Still though not sure why I need to specify all template parameters.
myOptionis a dependent name, it will work withthis->