want a family of unique classes, how about
template <unsigned N>
class D : public B
{
public:
D(const std::string& id) : B(id) {}
};
template <unsigned N0, unsigned N1>
class DD : public D<N0>
{
public:
D(const std::string& id) : D<N0>(id) {}
};
then you can instantiate D<1>, D<2>, DD<1,1> etc.
Thanks, but I was looking for something more generic. For instance,
this inheritance tree could be deeper (imagine having like 20 classes,=
and a tree depth of 5 for instance). Also, I named the classes like
D1, D11, etc. but it was just for brevity. In a normal situation, I'd
use a proper name in each case. This is why I'd like some generator
that also names the classes I want to instantiate, and also defines
its hierarchy.
Would it be possible to achieve this?
add functionality to their base.