> Thank you for your reply. > I have modify the program in the following way: > > #include <vector> > using namespace std; > > template <class T>void my_fun2(); > > template <class T> void > my_fun1(){ > my_fun2<T>(); > }; > > template <class T> void > my_fun2(){ > T prova=1234; > }; > > int main() > { > my_fun1<float>(); > return 0; > }; > > But now the compiler tell me that there is an error in my_fun2. > Please help me. > > the code above should be correct (and compiles with g++). (BTW: Please don't say "there is an error ...", but give **details**!! Just copy the error message. And perhaps better send your mail (also) to the list so that other people can participate and/or learn from it.) Oliver > > > > >-- Messaggio Originale -- > >Date: Sat, 22 Nov 2003 13:44:42 +0000 > >From: Oliver Kullmann <O.Kullmann@xxxxxxxxxxxxx> > >To: codaditasso@xxxxxxxxxx > >Subject: Re: gcc and template > > > > > >> > > Hello > > I've tried to compile the following program with gcc: > > > > 1 template <class T> void > > 2 my_fun1(){ > > 3 my_fun2<T>(); > > 4 }; > > 5 > > 6 template <class T> void > > 7 my_fun2(){ > > 8 T prova=1234; > > 9 }; > > 10 > > 11 int ma > >n() > > 12 { > > 13 my_fun1<float>(); > > 14 > > 15 return 0; > > 16 } > > > > but the compiler tell me that there is syntax error before > in line 3. > > Anyway with the c++ builder the program was compiled correctly. What's > the > > problem? Also with t > >e mingw I've obtained the same compile error? > > In the gcc are not possible to call a template function with in another? > > > > > > Greetings from pinzi > > > > Hi, > > at line 3 you are using a non-dependent name ("my_fun2"), and non-dependent > names > >n template definitions are looked up immediately (while dependent > names are looked up at the point of instantiation). > > So you need to declare my_fun2 before the definition of the function template > my_fun1: > > template <class T> > void my_fun2(); > > > > 1 template <class T> void > > 2 my_fun1(){ > > 3 my_fun2<T>(); > > ... > > Oliver > > Oliver > > > > > > __________________________________________________________________ > Tiscali ADSL SENZA CANONE, paghi solo quando navighi! > E in più il modem e' GRATIS! Abbonati subito. > http://point.tiscali.it/adsl/index.shtml > > > >