Originally Posted by
Sebastiani
>> Note that there is a difference between these two:
how so?
becuase the second is a tricky b@$tard!
Code:
class X
{};
X anX; // constructs an object of type X, right?
X anotherX(); // does the same, just explicitly calls the default constructor, correct?
NOPE!
what if I type
Code:
X getX(); // obviously a function declaration returning X
// NOT A INSTANCE OF AN OBJECT!
I didn't actually believe this until I tried it. Scott Meyers calls it "C++'s most vexing parse"
BTW you can get around this, by requiring functions with no arguements to take void in your coding standard.
e.g.
Code:
void DoStuff(void);
I actually think there should be a compiler switch to require this, at least as a warning.