blob: e8b595d8f28e797e300a98a1c7983977bf736ced (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <stdio.h>
//extern int printf(const char *, ...);
int CN = 0;
int DN = 0;
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);
struct bar {
~bar() {
printf("bar dtor\n");
}
} Destructor1; // Global with dtor
int main() {
printf("main\n");
return 0;
}
|