class A{ private: string a; public: A():a("hello world"){}; A(const string & arg):a(arg){}; void put()const{cout<<a;}; }; A aaa(); A bbb;
So what is the difference between A aaa(); and A bbb; Is aaa like a function?
A aaa();
A bbb;
aaa
Yes, the first is interpreted as a function declaration. It was named Most Vexing Parse .
Source: https://habr.com/ru/post/909244/More articles:How tolerable is weak communication? #pragma weak my_symbol - cWhy does a variable assigned by value to an array element (after an earlier assignment by reference) change when the array element changes? - arraysWhy doesn't Android have mac address for 3g when iOS? - androidWhere does the default mb_internal_encoding () come from? - phpWhy is my internal encoding ISO-8859-1 when I specified utf-8 in my php.ini file? - phpunconditional processing warnings - rC #: overload constructors with optional parameters and other arguments? - c #Emacs mode for c-like language - colorsPHP Extracting Similar Parts from Multiple Lines - stringPerform early execution - javascriptAll Articles