How do you implement this Python idiom in C++

alainpoint at yahoo.fr alainpoint at yahoo.fr
Thu Jul 27 12:25:48 EDT 2006


Jon Clements wrote:
> alainpoint at yahoo.fr wrote:
> > // Curious class definitions
> > class CountedClass : public Counted<CountedClass> {};
> > class CountedClass2 : public Counted<CountedClass2> {};
> >
> > It apparently works but in fact it doesn't:
> > If you derive from such a class, you get the count of the parent class,
> >
> > not of the derived class.
> > class CountedClass3 : public CountedClass {};
> >
>
> Hint: where's the template parameter gone as per the previous two
> statements...
>
> Jon.

You miss the point; i want to derive a class and inherit all properties
without worrying about those implementation details. The Python code is
much cleaner in that respect. My post is about whether it is possible
to get such a clean interface in C++

Alain




More information about the Python-list mailing list