• Advertisement
Sign in to follow this  

C++: Is there a copy of a templated class for subclasses?

This topic is 4470 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'm working on my game engine and I want to add an object factory. I'd like to make it templated, but I had one small question. Is there a copy of the templated class for each subclass? For example: templated singleton class TObjectFactory base class CRenderable sub class of CRenderable: CUnit Will there be a copy of TObjectFactory for CRenderable and CUnit, or are they both stored in the copy? (I use templates all the time, but I don't know all of the details.) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
If you mean will instantiating TObjectFactory for CUnit also generate an instantiation for CRenderable, the answer is no.

EDIT: Rereading I think I know what you're after....no doubt your object factory has an internal static list of registered types that it can create, TObjectFactory<CUnit> and TObjectFactory<CRenderable> are separate types and will each have separate lists, even though CUnit derives from CRenderable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement