Hello,
I have the following code
---
template < typename T>
struct Base
{
T base_member;
};
template < typename T>
struct Child: public Base <T>
{
T myfunc(){ return base_member; }
};
int main(){
Child<intchild;
return 0;
}
---
To my surprise it does not appear to compile (using g++ 3.4):
temptest1.cpp: In member function `T Child<T>::myfunc()':
temptest1.cpp:10: error: `base_member' was not declared in this scope
However changing the myfunc() line to
T myfunc(){ return Base<T>::base_member; }
makes it work fine. Does anyone know why i have to explicitly define
the namespace ? I don't understand why it should be ambigous which
base_member i mean, since there's only one base class ? Is there a way
to make it work implicitly ?
Thanks for any help,
Mike