Sign in to follow this  
Programmer16

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

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

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