1) what is the return value of following statement:
obj.classX::classX();
2) Another question regarding constructors in C++:
classX();
creates an object. What is the expanded code generated by the compiler?
1) what is the return value of following statement:
obj.classX::classX();
2) Another question regarding constructors in C++:
classX();
creates an object. What is the expanded code generated by the compiler?
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.
void
. You can't actually call the constructor that way though, so it matters little.obj.classX::classX();
This is compile time error.
classX();
This creates a temporary instance of classX
that is destroyed right at the end of the statement, IOW at the semicolon.