typedef in class
Gregory Mounie
Gregory.Mounie@imag.fr
Fri Sep 5 06:59:00 GMT 1997
Hello, I am using egcs970904. I like a lot the new template
implementation (especially static in templated classes), but i didn't
find how to use a typedef defined in a class in a templated function
(it works with non-templated function)
It seems to be a bug as g++ 2.7.2 works nicely.
let me show the problem
----- begin --------
#include <iostream.h>
class A
{
public:
typedef int titi; // typedef define in a class
int a;
};
template <class C>
void toto(C c) // templated function
{
C::titi t; // templated typedef, the error(l 13) is here
t= c.a;
cout << t << endl;
}
main()
{
A b;
b.a=1;
toto(b); // instantiation of the generic function
}
----- end ----
on sparc-sun-solaris gcc 2.7.2.f.1 it works nicely.
on i386-pc-solaris egcs 970904 it does not compile
>g++ -Wall T.C
T.C: In function `void toto(C)':
T.C:13: parse error before `;'
T.C: In function `void toto(class A)':
T.C:15: `t' undeclared (first use this function)
T.C:15: (Each undeclared identifier is reported only once
T.C:15: for each function it appears in.)
Any Idea ?
Gregory
More information about the Gcc-bugs
mailing list