Sign in to follow this  

Templates and Visual C++ 6.0

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

Is it possible to separate a template class declaration from its definition without getting linker errors? The only way to avoid the linker errors seems to be moving the definitions to the header file. If this is the only way around the issue, I guess I'll have to stay with throwing everything in the header file. Are there any other alternatives? Any help would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
The short answer is no.

Unless your compiler supports the export keyword, and MSVC doesn't, then you can't put the definition of a template in a separate source file without explicit instantiation for specific types. Without explicit instantiation, the complete definition of the template needs to be available at point of instantiation, which means, in effect, that the definition needs to go into the header. (Or an inline file of some sort, etc.)

Share this post


Link to post
Share on other sites
A) Stop using buggy IDE's/Compilers. Microsoft Visual C++ Express Edition is free now in every sense.

B) I place my templated code into .inl files that I include at the bottom of the header file.

Share this post


Link to post
Share on other sites

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