OOP / language design question

Duncan Booth duncan.booth at invalid.invalid
Thu Apr 27 04:23:49 EDT 2006


Lawrence D'Oliveiro wrote:

>>In other words, the object is constructed in Python before any
>>__init__ is called, but in C++ it isn't constructed until after all
>>the base class constructors have returned.
> 
> But if "construction" is what a constructor does, then you're wrong.
> 
I may be wrong (my C++ is getting rusty), but my belief is that if you have 
a base class B and a derived class D, then until the B() constructor has 
returned, the type of the object (as indicated by RTTI or by calling 
virtual methods) is a B. It isn't until after the B constructor has 
returned that the object is changed into a D.

This is different from Python's behaviour where the object is created as 
its final type and then initialised.



More information about the Python-list mailing list