Could you explain why the output of the code is nothing. My understanding is that "A a()" calls the "A(int a)..." function but f | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Could you explain why the output of the code is nothing. My understanding is that "A a()" calls the "A(int a)..." function but f

#include <iostream> using namespace std; class A{ public: A(){cout<<"It's A class";} A(int a){cout<<"A";} }; int main() { A a(); return 0; }

26th Aug 2017, 12:53 AM
Aurora
1 Answer
+ 1
A a(); actually creates a function called a with no body. A a; is all you would need to call the default parameterless constructor. https://stackoverflow.com/questions/5300124/calling-the-default-constructor
26th Aug 2017, 1:08 AM
ChaoticDawg
ChaoticDawg - avatar