Why is ‘this’ a pointer and not a reference?

I was reading the answers to this question C++ pros and cons and got this doubt while reading the comments. programmers frequently find it confusing that “this” is a pointer but not a reference. another confusion is why “hello” is not of type std::string but evaluates to a char const* (pointer) (after array to pointer … Read more

What are all the common undefined behaviours that a C++ programmer should know about? [closed]

It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago. Locked. This question and its answers are locked … Read more

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