in the code below, why does T2 give this error ‘m_t’ was not declared in this scope
, while TB is fine ?
And how can I have access to T1's members in T2 while still using templates ?
// All good
class TA
{
public:
TA() {}
protected:
int m_t;
};
class TB : public TA
{
public:
TB() {}
int get()
{ return m_t; }
protected:
};
// Error in T2
template<typename T>
class T1
{
public:
T1() {}
protected:
int m_t;
};
template<typename T>
class T2 : public T1<T>
{
public:
T2() {}
int get()
{ return m_t; }
protected:
};