[EMAIL PROTECTED] wrote:
> Rob Williscroft wrote:
>
> > If this is more than idle curiosity I strongly suggest you post
> > a version of the python code you need to translate to C++.
>
> For the moment this is just healthy curiosity but i will still post the
> code i would like to see translated:
>
> class Parent:
>       count=0
>       def __init__(self):
>               self.__class__.count +=1
>       @classmethod
>       def getcount(cls):
>               return cls.count
>
> class Child(Parent):
>       count=0 # replace this line by a 'pass'  statement if you don't want
> to reinitialise the count
>
> a=Parent()
> b=Parent()
> print Parent.getcount()  # you get 2
> c=Child()
> d=Child()
> e=Child()
> print Child.getcount() # you get 3 (you could get 5 if you don't
> reinitialise the count)

What happens if you print Parent.getcount() now?

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to