It's a simple question.crying

Asked 2 years ago, Updated 2 years ago, 23 views

I can't upload the picture.

using namespace std;

int cmxObjCnt=0;

class SoComplex { public: SoComplex() { cmxObjCnt++; cout<<cmxObjCnt<<"Third Object"<<endl; } SoComplex(SoComplex &copy){ cmxObjCnt++; cout<<cmxObjCnt<<"Third Object"<<endl; } };

int main() { SoComplex com1; SoComplex com2=com1; SoComplex(); return 0; }

This is an example of Yoon Sungwoo's passionate C++ I wrote it down except for some codes. But SoComplex() in the main; calls the constructor in the SoComplex class? Can you call the constructor separately like that?

c++

2022-09-22 13:54

1 Answers

Yes, it is correct to call the SoComplex() default constructor in the class.


2022-09-22 13:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.