MYINT()
can, depending on context, be interpreted as an expression of type MYINT
, or a specifier of a function type taking no arguments and returning MYINT
.
In some situations, where either an expression or a type specifier is valid, this gives an ambiguity; this is resolved by interpreting it as a type specifier if possible (EDIT: C++03 8.2/2, if you want a Standard reference).
sizeof
can take either an expression, or a parenthesised type specifier, as it's argument, giving this ambiguity. So here MYINT()
is interpreted as a type specifier; then you get an error, since sizeof
can't be applied to a function type.
EDIT: You can fix the error by removing the parentheses so it will be interpreted as an expression (sizeof MYINT()
), adding extra parentheses so it isn't a valid type specifier (sizeof((MYINT()))
), or changing it to the correct type (sizeof(MYINT)
).
cout << MYINT()
is unambiguous, so there should be no error, and indeed there isn't on my compiler. What is the error, and what is your compiler?