This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

template inheritance & this->


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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]