引用的声明周期结束时,并不会调用析构函数,只有本体的声明周期结束时,才会调用析构函数
example
1 class Test 2 { 3 public: 4 Test() { cout << "construct" << endl; } 5 ~Test() { cout << "destruct" << endl; } 6 }; 7 8 int main() 9 { 10 Test t1; 11 { 12 Test& t2 = t1; 13 } 14 cout << "............................." << endl; 15 return 0; 16 }
结果: