|
From: <ad...@ya...> - 2003-11-08 09:50:13
|
hello list
I have a template function problem. these are my files
and my outputs
************** test.h *******************
#include <iostream>
template <class T>
void test(T x);
****************test.cpp ***************
#include "test.h"
template <class T>
void test(T x){
cout << x <<endl;
}
****************main.cpp *************
#include "test.h"
main(){
test(5);
}
****************** ouputs ******************
[root@linuxserver cpp]# g++ -c test.cpp
Dans le fichier inclus à partir de test.cpp:1:
test.h:3:16: AVERTISSEMENT: pas de nouvelle ligne à la
fin du fichier
test.cpp:5:2: AVERTISSEMENT: pas de nouvelle ligne à
la fin du fichier
[root@linuxserver cpp]# g++ -c main.cpp
Dans le fichier inclus à partir de main.cpp:1:
test.h:3:16: AVERTISSEMENT: pas de nouvelle ligne à la
fin du fichier
main.cpp:4:2: AVERTISSEMENT: pas de nouvelle ligne à
la fin du fichier
[root@linuxserver cpp]# g++ main.o test.o -o test
main.o: In function `main':
main.o(.text+0x16): undefined reference to `void
test<int>(int)'
collect2: ld a retourné 1 code d'état d'exécution
[root@linuxserver cpp]#
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
|