template <class T>
class A
{
T a;
public:
A(T x=0):a(x){}
const T& GetA(){return a;}
};
class B: public A<int>
{
int b;
public:
B():b(1){}
void AB();
}b;
void B::AB()
{
cout<<GetA()<<' '<<b<<endl;
}
int main()
{
B b;
b.AB();
return 0;
}
/***************************************************************************
*****/
And I get
D:\users\max\test\temp\main.cpp(222) : error C2838: illegal qualified name
in member declaration if I nest class B inside C here:
template <class T>
class A
{
T a;
public:
A(T x=0):a(x){}
const T& GetA(){return a;}
};
class C
{
class B: public A<int>
{
int b;
public:
B():b(1){}
void AB();
}b;
void B::AB()/************ compile error here ****************/
{
cout<<GetA()<<' '<<b<<endl;
}
public:
void AB(){b.AB();}
};
int main()
{
C c;
c.AB();
return 0;
}
There is a reason I want the function definition to be outside the
declaration of B but inside C (some macro scheme I am using here). Is there
a way to get around this?
thanx,
max.
Sorry, no. You either define a member function inside its class or in the
appropriate namespace scope.
--
Doug Harrison
dHar...@worldnet.att.net
Visual C++ MVP