Jump to content
  • Advertisement
Sign in to follow this  
kappa

templates

This topic is 4592 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

Could anyone tell me how to get this functionality that I want? I have this function in a class
template<class T>
	void DrawToBuffer( std::vector<T> &objects );



which I call like this:
e->DrawToBuffer( objects );	



compiling this I get the following error: Error 70 error LNK2001: unresolved external symbol "public: void __thiscall _CEngine::DrawToBuffer<class _CSpaceShip>(class std::vector<class _CSpaceShip,class std::allocator<class _CSpaceShip> > &)" (??$DrawToBuffer@V_CSpaceShip@@@_CEngine@@QAEXAAV?$vector@V_CSpaceShip@@V?$allocator@V_CSpaceShip@@@std@@@std@@@Z) main.obj So basicly, I would like the array objects to be able to contain any class type to be sent to my draw function. How do I do that?

Share this post


Link to post
Share on other sites
Advertisement
It looks like you didn't provide definition of your templated function. When using templates your definitions of templated classes/functions have to be in same compilation unit as declaration.
If you have method implemented in another file then you just need to move it to the header.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!