博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
匿名对象中调用匿名对象是危险行为
阅读量:4212 次
发布时间:2019-05-26

本文共 564 字,大约阅读时间需要 1 分钟。

具体看如下代码:

#include "iostream"using namespace std;//构造中调用构造是危险的行为class MyTest{public:	MyTest(int a, int b, int c)	{		this->a = a;		this->b = b;		this->c = c;	}	MyTest(int a, int b)	{		this->a = a;		this->b = b;		MyTest(a, b, 1000); //产生新的匿名对象,匿名对象销毁时,也会调用析构函数	}	~MyTest()	{		printf("MyTest~:%d, %d, %d\n", a, b, c);	}protected:private:	int a;	int b;	int c;public:	int getC() const { return c; }	void setC(int val) { c = val; }};int main(){	MyTest t1(1, 2);	printf("c:%d", t1.getC()); //请问c的值是?, c是乱码	system("pause");	return 0;}/**输出:MyTest : 1,2,1000c:-858993460  */

 

转载地址:http://aezmi.baihongyu.com/

你可能感兴趣的文章
v$sql,v$sqlarea,v$sqltext 和 v$sql_plan 说明
查看>>
ORA-31623 When Submitting a Datapump Job [ID 308388.1]
查看>>
Oracle SYSAUX 表空间 说明
查看>>
RAC 安装patch 后启动实例 报错 ORA-00439 feature not enabled- Real Application Clusters 解决方法
查看>>
On RAC, expdp Removes the Service Name [ID 1269319.1]
查看>>
Important Changes to Oracle Database Patch Sets Starting With 11.2.0.2 [ID 1189783.1]
查看>>
Oracle RAC 平台下 Patch 安装与卸载 步骤
查看>>
Oracle Database 11gR1 和 10gR2 ASM Best Practices 说明文档
查看>>
ASM Concepts Quick Overview [ID 1086199.1]
查看>>
PowerDesigner 业务处理模型( BPM ) 说明
查看>>
PowerDesigner 企业架构模型 ( EAM ) 说明
查看>>
PowerDesigner 正向工程 和 逆向工程 说明
查看>>
PowerDesigner 模型文档 说明
查看>>
PowerDesigner 系列 小结
查看>>
Oracle 升级10.2.0.5.4 OPatch 报错Patch 12419392 Optional component(s) missing 解决方法
查看>>
Oracle sessions,processes 和 transactions 参数 关系 说明
查看>>
RMAN 备份报错 RMAN-06207 RMAN-06208 解决方法
查看>>
[INS-35172] Target database memory (XXMB) exceeds the systems available shared memory ({0}MB) 解决方法
查看>>
深入理解 OUI(Oracle Universal Installer)
查看>>
Oracle LOB 详解
查看>>