+ 5
Object of class
What is difference between below line of code? Assume A is class name and a is object. now, does A a; and A a(); are same? First one is nothing but default constructor...What does second object represents?
4 odpowiedzi
+ 3
it doesn't call default A a if we declare object like A a(). try simple code and you may observe it...
+ 2
A a; A a(); and A a{}; are all the same, but the last one is the default C++ way to define something, it implicitly makes more checks and it is more strict. Appart from that, when doing A a; by default, it calls the default constructor A a(); unless otherwise specified.
More info on this:
https://www.quora.com/Whats-the-difference-between-brace-and-parentheses-initialization-in-C++11
+ 2
Ketan Lalcheta it looks like it is not proper way to define a object.
First I thought maybe compiler have generated temporary object but it is not.
I have verified it through default constructor, parameterized constructor with default argumnet and also with copy constructor but it is showing non class of type.
here is my sample code.
https://code.sololearn.com/cMCycvHWqX7G/?ref=app
- 1
duplicate. based on what you use to compile the code.