0

Can someone explain this program to you?

class A { public: A(){cout<<"a";} A(const A&x){cout<<"b";} } int main() { A x; A y(x); }

5th May 2018, 5:13 PM
Akash papnai
Akash papnai - avatar
3 Answers
+ 2
I dunno why you tagged it C, this is C++. It's a class with an overloaded constructor and (very bad) implicit destructor. The main function creates object x of type A, then object y of type A, passing x as it does so in the latter case.
5th May 2018, 6:28 PM
non
+ 4
No prob, I'm used to language barriers, printos/typos, etc.
6th May 2018, 9:14 PM
non
0
sorry, that was a huge mistake. BTW, thanks for the answer. Also, there is one more mistake in the question itself. I've written you instead of me.😄
6th May 2018, 12:25 PM
Akash papnai
Akash papnai - avatar