Template class heritance strange behaviour

John Love-Jensen eljay@adobe.com
Wed Mar 14 14:43:00 GMT 2007


Hi rodrigob,

>     //c = _d; // <<< this line generates error : 'c' was not declared
> in this scope

Yep, that is an error. That line (if uncommented) is bad C++.

>     this->c = _d; // this access work  fine

Yep, that is correct.  That's C++.

>     Parent<T2>::c = _d; // this access work  fine too

Yep, that is correct.  That's C++, too.

In Child, I think you can also use something like:

  using Parent<T2>::c;

Google for "Koenig lookup" (two phase lookup) if you want details.

Here's one URL:
http://h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,9
90,00.html

HTH,
--Eljay



More information about the Gcc-help mailing list