Jump to content
  • Advertisement
Sign in to follow this  
ZergUser

Templates and Visual C++ 6.0

This topic is 4029 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
Advertisement
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
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!