在C ++中显式构造函数调用 [英] Explicit constructor call in C++
本文介绍了在C ++中显式构造函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1)以下语句的返回值是什么:
1) what is the return value of following statement:
obj.classX::classX();
2)关于C ++中构造函数的另一个问题:
2) Another question regarding constructors in C++:
classX();
创建一个对象。编译器生成的扩展代码是什么?
creates an object. What is the expanded code generated by the compiler?
推荐答案
构造函数不返回值。就像为你的第二个问题返回 void
。
Constructors do not return a value. Just like a function returning void
.
的函数,编译器将调用构造函数, 。
for your 2nd question, the compiler will call the constructor, then the destructor.
这篇关于在C ++中显式构造函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文