default constructor == constructor without argument?
If an object is instantiated without brackets, is it the same as having empty brackets?
Code:
class A { ... };
A a;
Code:
class A { ... };
A a();
Are they the same?
The only way I can get different "behaviours" out of them is
Code:
class A {
A() {}
};
int main() {
A a();
}
vs
Code:
class A {
A() {}
};
int main() {
A a;
}
Note that the constructor is private. Both work if it's declared public.
The first one compiles fine, but the second one gives
Quote:
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
Anyone care to enlighten me?
Thanks