If an object is instantiated without brackets, is it the same as having empty brackets?
Code:class A { ... }; A a;Are they the same?Code:class A { ... }; A a();
The only way I can get different "behaviours" out of them is
vsCode:class A { A() {} }; int main() { A a(); }
Note that the constructor is private. Both work if it's declared public.Code:class A { A() {} }; int main() { A a; }
The first one compiles fine, but the second one gives
Anyone care to enlighten me?cyberfish@cyberfish-desktop:/tmp$ g++ a.cpp
a.cpp: In function ‘int main()’:
a.cpp:2: error: ‘A::A()’ is private
a.cpp:6: error: within this context
Thanks