Advertisement Jump to content
Sign in to follow this  
Fish Fishes

External templates

This topic is 4999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Receiving error: error LNK2019: unresolved external symbol "public: void __thiscall moBitmap<unsigned int>::Copy(unsigned int *,int)" (?Copy@?$moBitmap@I@@QAEXPAIH@Z) referenced in function "unsigned long __stdcall moPrepareThread(void *)" (?moPrepareThread@@YGKPAX@Z) How to organize cpp file?

Share this post

Link to post
Share on other sites
In practice, the implementation of the template needs to be available in the same translation unit that uses it. This means that (on almost any compiler) the following does not work:

temp.h: template declaration
temp.cpp: template definition (implementation)
program.cpp: includes temp.h

Instead, do this:

temp.h: template declaration and definition
program.cpp: include temp.h

In other words, don't put the template implementation in a separate file.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!