I have the following code and it fails to compile
template < typename T >
class Base
{
public:
typedef T * TPtr;
void func()
{
}
};
template < typename T >
class Derived : public Base< T >
{
public:
using Base< T >::TPtr;
using Base< T >::func;
TPtr ptr;
};
int main( int c, char *v[] )
{
Derived< int > d;
d.func();
}
The compiler issues the following.
t.cpp:16: error: 'TPtr' does not name a type
t.cpp:16: note: (perhaps 'typename Base<T>::TPtr' was intended)
Now I know I could simply do as the compiler is suggesting but I can't understand why the
using Base< T >::TPtr;
doesn't work.
If I comment out the "TPtr ptr
" line then it compiles, proving that the "using Base< T >::func;
" statement works.
Any ideas?