Hello everybody,

I have a template class (e.g. MyBaseClass) . It contains several protected attributes and I derive it (e.g. MyClass)

Ex:
___________________________________________________________________________________
template <class t1, class t2> class MyBaseClass
{

protected:
  t1* myT1;
  t2* myT2;
};


template <class t1, class t2> class MyClass : public MyBaseClass<t1, t2>
{
public:
        void MyMethod()
        {       t1* _t1 = myT1; // ERROR :'myT1' was not declared in this scope
                t2* _t2 = myT2; // ERROR :'myT2' was not declared in this scope
        }       
        void MyMethod1()
        {       t1* _t1 = MyBaseClass<t1, t2>::myT1;      // OK
                t2* _t2 = MyBaseClass<t1, t2>::myT2;      // OK
        }       
};
_____________________________________________________________________________________

When I try to use the protected attribute directly (e.g. t1* _t1 = myT1; in MyMethod()) error occurs of type : error : 'myT1' was not declared in this scope.

If I use the orthography implemented in MyMethod1(), everything works properly.

I am sure there is a flag in the gcc compiler which solves globally this kind of situation.

Thanks in advance for your help,
Gelu Ionescu
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to