Answer the question
In order to leave comments, you need to log in
What is the difference between int a() and int a=int()?
I know it sounds silly and I wouldn't be asking if I hadn't experimented in the console
int first (); // first == 1
int two = int (); // two == 0
AnyType anyObject ()
, what AnyType anyObject = AnyType ()
is a constructor call, but with primitives?
Answer the question
In order to leave comments, you need to log in
Now print typeid(first).name() to the screen and be surprised.
The first line is the declaration of the function first without parameters and returning an int. The function name is converted to a pointer, the pointer is converted to bool(true) which is converted to int(1).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question