参考资料:
1. https://blog.csdn.net/luomoshusheng/article/details/48226517
2. https://blog.csdn.net/wangshubo1989/article/details/49913239 (妙得很)
3. https://www.cnblogs.com/biyeymyhjob/archive/2012/09/12/2674004.html
贴两段代码防忘记:
当存储类对象的指针时,析构和结构的过程分析:
#include <iostream>
#include <vector>
using namespace std;
class Test
{
public:
Test(void);
~Test(void);
};
Test::Test(void) {
cout << "object created\n";
}
Test::~Test(void) {
cout << "-->object deleted\n";
}
int main() {
vector<Test*> vec;
Test* t1