Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DanG

Correct way to put template classes in files?

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

What is the correct way to organize files for a templated class with defined functions. I tried the standard .h and .cpp with #include .h, but that caused many compiler errors. What is the correct way?

Share this post


Link to post
Share on other sites
Advertisement
of you can name the file whatever.template, and do #include whatever.template at the bottom of your whatever.h file. That hides the implementation at least a little bit.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
For all my templated and normal classes, I put the class definition first, then the inlined/template member functions at the end of the class''s definition. This allows me to include headers needed by the template/inlined member functions after the class definition.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!