I have 3 class which derived from each other:
class Basic{
...
}
class Extended : public Basic{
...
}
class Full : public Extended{
...
}
I have a template class which holds 5-5 from this classes:
template <class T>
class group{
public:
...
private:
T one, two, three, four, five;
};
group<Basic> basicGroup;
group<Extended> extendedGroup;
group<Full> fullGroup;
Can I easily cast for example fullGroup to basicGroup or extendedGroup to basicGroup? (I just want to cast upward)
A solution would be to create a kind of view-class that can wrap a group, and exposes the individual objects as base-class instances:
You could use it like this:
If you extract the public interface of
groupinto an abstract base class, you can even usegroup_views polymorphically.