string& foo()
{
string* str = new string("abc");
return *str;
}
struct a_s
{
int a;
};
a_s* foo()
{
struct a_s* sp = new struct a_s;
return sp;
}
string& tmp = foo(); string str = tmp; delete &tmp;
#include <iostream>
using namespace std;
class example
{
public:
example()
{
num = new int;
*num = 10;
cout<<"num = "<<*num<<endl;
cout<<"构造"<<endl;
}
~example()
{
cout<<"析构"<<endl;
delete num;
}
void pingfang()
{
*num *= *num;
}
void print()
{
cout<<*num<<endl;
}
private:
int *num;
};
example & diaoyong1()
{
example * p = new example;
p->pingfang();
return *p;
}
example * diaoyong2()
{
example * p = new example;
p->pingfang();
return p;
}
int main(void)
{
example & e1 = diaoyong1();
e1.print();
delete &e1;
example * ptr = diaoyong2();
ptr->print();
delete ptr;
getchar();
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有