Different ways of constructing an object in C++
问题 I want to construct an object in the stack, using C++. Do you know what is the difference between these to ways of calling the constructor (with and without parenthesis): a) MyClass object ; b) MyClass object() ; I am using MFC and when constructing the global variable for the main app, if I use the latter way, I get an exception, I thought these two ways were equivalent. Thank you guys for any information. 回答1: This is one of those gotchas of C++. MyClass object(); is the way that a function