|
|
JoseMariaSola <JoseMariaSola@xxxxxxxxx> writes:
[...]
> Talking with you both I notice that every operator requires
> expressions as operands, and type-name is not an expression. Am I
> right?
Ideally, yes, but C is not an ideal language (not that I'm arguing it
needs to be).
"sizeof" is a unary operator; its operand can be either an expression
(specifically a unary-expression) or a parenthesized type name.
Or, if you prefer, "sizeof ( type-name )" is a special form of
expression. You don't *have* to think of the parenthesized type name
as an operand. But the standard puts it in the same section with the
real unary operators, probably because the other form of "sizeof" is
in that section. It would have been more logical, but less clear, to
separate them.
"." and "->" could be thought of as binary operators whose right
operand is an identifier, but the standard treats them as postfix
operators. Given:
struct foo { int x; int y; };
you can think of ".x" and ".y" as two distinct postfix operators, both
applicable to operands of type "struct foo".
--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|