2003-05-14 03:40:31 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
//extern int printf(const char *, ...);
|
2003-05-14 02:09:44 +08:00
|
|
|
|
2003-05-14 03:40:31 +08:00
|
|
|
int CN = 0;
|
|
|
|
int DN = 0;
|
2003-05-14 02:09:44 +08:00
|
|
|
|
2003-05-14 03:40:31 +08:00
|
|
|
struct foo {
|
|
|
|
int Num;
|
|
|
|
foo(int num) : Num(num) {
|
|
|
|
printf("Foo ctor %d %d\n", Num, CN++);
|
|
|
|
}
|
|
|
|
~foo() {
|
|
|
|
printf("Foo dtor %d %d\n", Num, DN++);
|
|
|
|
}
|
|
|
|
} Constructor1(7); // Global with ctor to be called before main
|
|
|
|
foo Constructor2(12);
|
2003-05-14 02:09:44 +08:00
|
|
|
|
|
|
|
struct bar {
|
2003-05-14 03:40:31 +08:00
|
|
|
~bar() {
|
|
|
|
printf("bar dtor\n");
|
|
|
|
}
|
2003-05-14 02:09:44 +08:00
|
|
|
} Destructor1; // Global with dtor
|
2003-05-14 03:40:31 +08:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
printf("main\n");
|
|
|
|
return 0;
|
|
|
|
}
|