Topic: Syntax of sizeof and typeid


Author: zunino@unu.edu (=?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=)
Date: Thu, 7 Feb 2002 15:26:14 GMT
Raw View
Hello.

'sizeof' and 'typeid' are both operators.

'sizeof' can be used with an identifier or with a type. When using it
with an identifier, the parentheses are optional.

int i = int();
sizeof i;
sizeof(i);
sizeof int; // not allowed
sizeof(int);

Now with 'typeid', it appears the parentheses are always required.

typeid i; // not allowed
typeid(i);
typeid int; // not allowed
typeid(int);

What is the reason for the inconsistency in the case of using the
operators with an identifier? I wish the syntax was the same, even
though the operators have distinct purposes. Is there any chance of
this being revised?

Thank you,

--
Ney Andr    de Mello Zunino

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]