目录
前言
* new申请的内存,即使你没有执行delete,在程序结束后,也会释放掉的。
* 但这样做会有很多弊端,下文将列举部分情况。
弊端
不delete的话被释放时不会执行析构函数
- 测试 - 在vs2022中:
- 定义一个test类,并在main函数中声明t1,t2,t3三个对象:
#include<iostream>
using namespace std;
class test
{
string name;
public:
test(const string& in_name)
{
name = in_name;
cout << "<< " + name + " 出现了,指针:" << this << endl;
}
~test()
{
cout << "<< " + name + "执行了析构函数,指针:" << this << endl;
}
};
int main()
{
test t1("t1");
test* t2 = new test("t2");
test* t3 = new test("t3");
cout << endl << endl;
delete t2;
cout << endl << endl << "<< main - return" << endl << endl;
return 0;
}
- 可以看到在main函数中,t2,t3是new出来的,我们手动把 t2 delete。
- 运行结果:
- 可以看到,t2因为我们手动delete而在main结束前执行了析构函数
- t1则main结束后执行了析构函数。
- t3则是由系统回收,可见它并没有执行析构函数
- 因此,如果析构函数中有输出提示,缓冲内容等需要执行,则应该手动delete。当然,即便没有也倡导自己手动delete。
https://ciprofloxacin.tech/# where can i buy cipro online
http://ciprofloxacin.tech/# buy cipro online
cytotec pills buy online buy cytotec over the counter cytotec online
nolvadex 20mg nolvadex for sale tamoxifen citrate
buy cipro online canada: cipro ciprofloxacin – ciprofloxacin 500mg buy online
https://lisinopril.network/# lisinopril 3.5 mg
cipro online no prescription in the usa: cipro 500mg best prices – buy ciprofloxacin
buy cytotec over the counter Cytotec 200mcg price cytotec pills buy online
https://ciprofloxacin.tech/# cipro for sale
cytotec pills online: Misoprostol 200 mg buy online – cytotec pills online
https://cytotec.club/# buy cytotec in usa
lisinopril brand name in india: buy lisinopril 20 mg online canada – zestoretic 20 12.5 mg
п»їcytotec pills online buy cytotec pills online cheap cytotec abortion pill
https://lisinopril.network/# zestril lisinopril
п»їcipro generic buy cipro cheap ciprofloxacin mail online
https://finasteride.store/# order generic propecia without prescription
https://ciprofloxacin.tech/# ciprofloxacin over the counter
order generic propecia without rx: order propecia – rx propecia
http://lisinopril.network/# zestoretic tabs
tamoxifen alternatives: should i take tamoxifen – tamoxifen cyp2d6
buying propecia without rx order cheap propecia no prescription buy propecia prices
tamoxifen pill tamoxifen premenopausal aromatase inhibitor tamoxifen
http://finasteride.store/# cost of propecia without insurance
lisinopril 15 mg tablets buy lisinopril canada buy zestoretic
how to get nolvadex: tamoxifen joint pain – nolvadex only pct
http://finasteride.store/# order cheap propecia without prescription
buy misoprostol over the counter Abortion pills online Abortion pills online
buy cipro cheap: ciprofloxacin – cipro 500mg best prices
https://nolvadex.life/# tamoxifen brand name
https://ciprofloxacin.tech/# buy ciprofloxacin over the counter
https://lisinopril.network/# zestril 20 mg
cytotec online buy misoprostol over the counter buy cytotec
buy cytotec pills Misoprostol 200 mg buy online cytotec online
https://ciprofloxacin.tech/# cipro ciprofloxacin
order generic propecia for sale: propecia cheap – cheap propecia tablets
lisinopril 10 mg coupon: lisinopril online usa – where can i purchase lisinopril
cytotec buy online usa order cytotec online cytotec abortion pill
п»їcytotec pills online buy cytotec over the counter Misoprostol 200 mg buy online
https://cytotec.club/# Abortion pills online
is nolvadex legal: raloxifene vs tamoxifen – tamoxifen adverse effects
buy generic ciprofloxacin: ciprofloxacin generic price – buy cipro cheap
buy lisinopril 20 mg online zestoretic generic zestril 5 mg india
buy cytotec online Misoprostol 200 mg buy online Misoprostol 200 mg buy online
http://finasteride.store/# buy propecia now
mexican rx online Mexican Pharmacy Online mexican drugstore online
canadian pharmacy world Prescription Drugs from Canada legitimate canadian online pharmacies
п»їbest mexican online pharmacies: cheapest mexico drugs – mexican pharmaceuticals online
https://indiaph24.store/# indianpharmacy com
http://canadaph24.pro/# canadian king pharmacy
https://indiaph24.store/# cheapest online pharmacy india