g++ and templates

Eljay Love-Jensen eljay@adobe.com
Thu Feb 21 14:40:00 GMT 2008


Hi Mihai,

> Can anyone tell me why the following code won't compile with g++ (4.1.2) ?

Because h was not declared in the scope it is being used in.

Try this:
A<T>::h = t;

Or try this:
this->h = t;

Or try this:
using A<T>::h; // In B, outside of foo.
h = t;

> It is, however, "digested" well by g++ 3.2.2 and g++ 3.3.4

GCC 3.2.x and 3.3.x were not C++ compliant on that issue.

Google for "two phase lookup".

HTH,
--Eljay



More information about the Gcc-help mailing list