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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | class TestArg { public: TestArg(int value1) :a(value1) { int b = 0; } ~TestArg(){ int bbb= 0; } int a; }; class OhMyGod { public: OhMyGod() :m_Arg(NULL) {} void set(TestArg* arg) { m_Arg = arg; } void print() { std::cout<< m_Arg->a; } private: TestArg* m_Arg; }; int _tmain(int argc, _TCHAR* argv[]) { OhMyGod god; { god.set(&TestArg(10)); } int qqq = 1000; { TestArg qq(2000); } god.print(); system("pause"); return 0; } |
Direct link: https://paste.plurk.com/show/393417