This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
template inheritance & this->
- From: "Grigorio V. Moshkin" <grigorio at garant dot ru>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 1 Feb 2005 18:46:56 +0300
- Subject: template inheritance & this->
- Organization: Garant
Hi!
Consider the following program:
-----------------------------------------
template<class A>
class Base {
public:
A data_a;
int count;
};
template<class A>
class Child: public Base<A> {
public:
void inc() {
this->count++;
this->data_a++; // ISO C++ ok, universal.
Base<A>::count++; // ISO C++ ok.
// Code below is bad!
data_a++; // ISO C++ denies! gcc 3.4.x doesn't compile!
count++; // ISO C++ denies! gcc 3.4.x doesn't compile!
}
};
-------------------------------------
Are the comments fully correct? I.e. ISO C++ really denies that,
and that's the only reason because gcc 3.4.x doesn't compile that?
(gcc 3.3.3 does).