Default constructor with empty brackets

Is there any good reason that an empty set of round brackets (parentheses) isn’t valid for calling the default constructor in C++?

MyObject  object;  // ok - default ctor
MyObject  object(blah); // ok

MyObject  object();  // error

I seem to type “()” automatically everytime. Is there a good reason this isn’t allowed?

9 Answers
9

Leave a Comment