[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
error when working with with protected attributes in template classes
From: |
Gelu Ionescu |
Subject: |
error when working with with protected attributes in template classes |
Date: |
Mon, 02 Jun 2008 12:28:19 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) |
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
- error when working with with protected attributes in template classes,
Gelu Ionescu <=