ar*********@yahoo.com wrote:
So when you have to create an object with default constructor you
should never use the paranthesis, otherwise the compiler thinks it as
a function call.
No, that's not true either.
Type()
is an expression that does *create* a temporary object using the
*default constructor*.
for other constructor (other than the default constructor) the
compiler knows it is not a declaration and does the right thing.
is that right?
It's other way around. If the compiler can interpret a statement
as a declaration rather than something else, it will.
struct Type { Type(int) {} };
char a = 42;
Type t(int(a)); // declaration of a function.
Type tt(a); // declares/defines/initialises an object
It takes time to get used to providing _less_ information than you
think necessary.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask