Re: Technical reason why sizeof() is an operator and not a function?



In article <dqit7c$7ab$1@xxxxxxxxxxxxxxxxxxxx>, kers@xxxxxxxxxx says...
> Gerry Quinn wrote:
>
> > int* ptr = malloc( 100 * sizeof( int ) );
>
> Too vulnerable to changes in the type of `ptr`. Shiver.

That's irrelevant to the question of whether sizeof should take
brackets.

That said, int pointers don't usually change. In C++ the equivalent
is:

int* ptr = new int[ 100 ];

...and that doesn't seem to bother anyone.

- Gerry Quinn
.