This code compiled and ran successfully:
[edit]Code:#include <iostream> using namespace std; class Test { public: Test() { cout << "Test" << (int)this << endl; } ~Test() { cout << "~Test" << endl; } void test(){cout <<"fun"<<endl;} }; int main() { Test& t = Test(); t.test(); cout << "main" << endl; return 0; }
Where did we create an object inWhenever you create an object
?Code:Test();