Hi,
I'm porting more code over to Xcode from Codewarrior and have run into
a new problem with template classes. I have a template class that is
derived from a template class derived from another non-template
class... so it is 3 levels deep. The first derived template class works
fine and I can access members defined in the base class. However, the
higher level template class produces an error when trying to access
members of the base class. This should work.
Am I missing something here? The following code will not compile:
class TestBase {
public:
long mTest;
};
template<typename X>
class TestA : public TestBase {
public:
long TestMeA() { return mTest + 1; } // this is fine
};
template<typename X>
class TestB : public TestA<X> {
public:
long TestMeB() { return mTest + 1; } // compile error: 'mTest' was not
declared in this scope
};
Thanks for any help!
Steven J. Walker
Walker Effects
www.walkereffects.com
steve@walkereffects.com
steve@walkereffects.com - 25 Apr 2006 04:31 GMT
I found the solution to this problem... the member needs to qualified
by the first template class:
long TestMeB() { return TestA<X>::mTest + 1; }