Possible Duplicate:
Why doesn't a derived template class have access to a base template class' identifiers?
Translating of the following program
A.h
#ifndef A_H
#define A_H
template <class T>
class A
{
protected :
T a;
public:
A(): a(0) {}
};
#endif
B.h
#ifndef B_H
#define B_H
template <class T>
class A;
template <class T>
class B: public A <T>
{
protected:
T b;
public:
B() : A<T>(), b(0) {}
void test () { b = 2 * a;} //a was not declared in this scope
};
#endif
causes an error: "a was not declared in this scope". (Netbeans 6.9.1).
But the construction
void test () { b = 2 * this->a;}
is correct... Where is the problem?
Is it better to use forward declaration or file include directive?
B.h
template <class T>
class A;
vs.
#include "A.h"