C++: Can I write a template class that derives from T? -



C++: Can I write a template class that derives from T? -

i'm not sure how word in english, want this:

template <class t> class derived: public t { blah };

where basically, have template class, i'm deriving new class class specified in template? i.e. wouldn't know class @ compile time.

is possible? if so, semantics this?

for example, i'm trying write "parent" class. purposes of example, let's it's tree parent. tree parent, tree (so inherits tree), has vector of references kid trees.however, parent class doesn't have tree; class, such write like:

parent<tree> treeparent; parent<shrub> shrubparent;

yes. possible. seek doing that.

i wouldn't know class @ compile time.

i think, mean "i wouldn't know class @ time of defining class template."

by time compile, you've defined class template, , used in code, passing template argument it, means know class (i.e template argument) @ compile time. if don't know class used base, cannot compile code.

c++ templates inheritance base derived

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -