hi this is about c++ strange linking and compilation phenomenon.
I created a general algorythm function in c++:
******** a.cpp ************
template <class T>
void readFile(T general)
{ ......
general.print(); }
*************************
As you can see, the function takes an object of type T and calls the print() function of that object.
One weird thing is that even if I change the line
general.print(); to be
stupid.print(); although there is no 'stupid' object defined, still the compilation of the function succeeds.
the function is called from main:
******** main.cpp ***********
#indlude "data.h"
data mdata;
template <class T>
void readFile(T general);
.....
readFile(mdata);
**************
ok, so the compilation works fine, but not the linking:
error LNK2001: unresolved external symbol.... is created
I would really apprise it, could you explain me how overcome this weirdness ?
[edited by - friman on April 29, 2003 5:28:54 AM]