
On 12/4/2010 6:49 PM, Abdullah ARSLAN wrote:
you seem to be right. I was using a header file for class declaration and a cpp file for definition, when i moved everything to cpp file, It worked.
But what is the problem? My header file contains template<class Archive> void serialize(Archive & ar, const unsigned int version);
and in cpp file template<class Archive> void g7GameObject::serialize(Archive & ar, const unsigned int version) { ar & height; ar & width; ...... } // my class name is g7GameObject
and with above code i get following error error LNK2019: unresolved external symbol "private: void __thiscall g7GameObject::serialize....
What am i doing wrong
In the typical template inclusion model, both the template declaration and the template definition need to be in a header file so that soure using the template can include that header file and get the full template code. If you put the definition in a source file it is quite likely that code which uses that template never "include"s that source file and therefore the template definition is missing when you link.