1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include <cstdio> class A { public: const char *msg; A(const char *msg) { printf("constr %s\n", msg); this->msg = msg; } ~A() { printf("destroy %s\n", this->msg); } }; A a("helloA"); A b("helloB"); int main() { printf("main\n"); return 0; }