Sign in to follow this  
mazelle

Don't split a template class

Recommended Posts

mazelle    106
I've learned in some website that it's not advisable to split a template class to .h and .cpp file. Maybe that was an old content. Does this still apply compilers today, say VS2005? If so, how do you create it in one file? How will you include the declaration for that class? Or am I even asking the correct questions?

Share this post


Link to post
Share on other sites
UziMonkey    143
The problem is if the source of the member functions are not available when you instantiate the template class then it cannot generate the specialized functions. You can either put it all in the header, make sure the cpp file is available and part of the compilation of the code that uses the class, or force template instantiation for all the specializations you'll need. The easiest way is probably to put all the code in the header.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this