skipping __init__ and using exploiting a class member instead

Roy Smith roy at panix.com
Sun Oct 20 08:55:46 EDT 2013


In article <abedb99b-336a-4bbe-9ddc-e98613853026 at googlegroups.com>,
 Peter Cacioppi <peter.cacioppi at gmail.com> wrote:

> Personally, I find the ability of Python to subclass without overriding the 
> constructor very elegant. I don't believe the other languages I've worked in 
> can do this (C++, C#, Java)...

I'm not sure what point you're trying to make here.  You certainly don't 
have to write a constructor for a subclass in C++.  This works perfectly 
fine (and prints "Foo" when I run it):

#include <stdio.h>

class Foo {
public:
    Foo() {
        printf("Foo()\n");
    };
};

class Bar : Foo {
};

int main(char**, int) {
    Bar b;
}



More information about the Python-list mailing list