Skip to content

Instantly share code, notes, and snippets.

@laruence
Created April 30, 2012 16:50
Show Gist options
  • Save laruence/2559963 to your computer and use it in GitHub Desktop.
Save laruence/2559963 to your computer and use it in GitHub Desktop.
C++ constructor
#include <cstdlib>
#include <cstdio>
class Base {
public:
Base() {
printf("base constructor called\n");
}
};
class Child : public Base {
public:
Child() {
printf("child constructor called\n");
}
};
int main(int argc, char **argv) {
Base *b = new Child();
delete(b);
}
//output:
base constructor called
child constructor called
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment