[LC++]template and gcc
Peter Poulsen
peter_poulsen at stofanet.dk
Mon Mar 25 02:50:05 UTC 2002
I have this little program
main.cpp:
#include "run.h"
void main()
{
run<int> r;
r.running();
}
run.h:
#include <iostream>
template< typename T >
class run
{
public:
void running();
};
run.cpp:
#include "run.h"
template< typename T >
void run<T>::running()
{
cout << "Running" << endl;
}
I compile it with the following command: g++ main.cpp run.cpp -o main
I get the following message:
/tmp/ccL9ZUDh.o: In function `main':
/tmp/ccL9ZUDh.o(.text+0xe): undefined reference to `run<int>::running(void)'
collect2: ld returned 1 exit status
I'm using gcc version 2.96
Can anybody see whats wrong? (note: if I write running in the header
file as an inline method, it all works smothly)
--
Yours/Med venlig hilsen
Peter Poulsen
Naessundvej 208
9220 Aalborg East
+45 98 15 47 05
More information about the tuxCPProgramming
mailing list