missing function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello
I have write the following files:

prova91.cpp:

1 #include "prova92.h"
2 
3 int
4 main(){
5      int k=1;
6      prova(k);
7      return 0;
8 };

prova92.h:

1 template <class T> void prova(T k);

prova92.cpp:

1 #include <iostream>
2 #include "prova92.h"
3 using namespace std;
4 template <class T> void
5 prova(T k){
6           cout<<k<<"\n";
7 };

 And the i have digit the following command to compile the program:

bash-2.05b# g++ -c prova91.cpp
bash-2.05b# g++ -c prova92.cpp
bash-2.05b# g++ -o prova9 prova91.o prova92.o

But i have obtained the following error from the last command:

prova91.o(.text+0x1e): In function `main':
: undefined reference to `void prova<int>(int)'
collect2: ld returned 1 exit status

What's the problem ? Maybe the template function and class must be written
only in the header files?

Greetings from Pinzi

__________________________________________________________________
Tiscali ADSL SENZA CANONE, paghi solo quando navighi!
E in più il modem e' GRATIS! Abbonati subito.
http://point.tiscali.it/adsl/index.shtml





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux