The member access about template derivation
There are two templates. One is base, another is child
1 2 3 4 5 6 7 8
|
//Base.h
template<typename T> class Base
{
protected:
int x;
char c;
};
|
1 2 3 4 5 6 7 8 9
|
//A.h
#include "Base.h"
template<typename T>class a: public Base<T>
{
public:
void test();
};
|
1 2 3 4 5 6 7 8
|
//A.cpp
#include "A.h"
template<typename T> void a<T>::test()
{
x++;
}
|
These is an error in the file "A.cpp".
The compile message is: error: 'x' was not declared in this scope.
How can I solve this problem? Thanks a lot.
Last edited on
Topic archived. No new replies allowed.