Sign in to follow this  

Don't split a template class

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

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
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

This topic is 3577 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.

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