If I have a template class defined as:
#ifndef A_HPP #define A_HPP template<class T> class A { public: int doSomething(int in, bool useFirst); private: template<int CNT> class B { public: int doSomething(int in); }; B<2> first; B<3> second; }; #include "a_imp.hpp" #endif
Now I can find the declaration for A::doSomething in the implementation header file like this
#ifndef A_IMP_HPP #define A_IMP_HPP template<class T> int A<T>::doSomething(int in, bool useFirst) { if (useFirst) return first.doSomething(in); return second.doSomething(in); } #endif
However, I do not know how I am declaring for a child class method. Is this possible, or do I need to do one of the other two ways that I can do this, namely defining methods in the main header or declaring a class outside A.
Please note that I use C ++ 11, so if it is possible only in that it will work for me anyway, although a C ++ 98 solution would be good for other people.
source share