At 11:34 PM 1/10/2002 +0000, Tom Hughes wrote:
>In message <20020110201559$[EMAIL PROTECTED]>
>           "Melvin Smith" <[EMAIL PROTECTED]> wrote:
>
>Well sizeof(Foo) and sizeof(*foo) are not actually the same thing
>at all there because Foo is presumably a typedef for a pointer type
>so sizeof(Foo) will be the size of a pointer and sizeof(*foo) will
>be the size of the thing it points to.

Right, I misread the code snippet in my infinite confusion.

>In general it is safer to sizeof() on the variable you are working
>with than on it's type, as that way the sizeof() will still work if
>somebody changes the type of the variable.

Well even after misreading the snippet the point I was
getting at was emulating virtual pointers in C++ where the
allocator might create an object regardless of what type of
pointer it was using or assigning to. For example in the case
where an allocator had in it a switch statement of subclasses.

In the end this is more the exception than the rule and I see
I was just on a tangent. :)

>The type of *foo is whatever Foo as been typedefed as a pointer
>to, and FooBar is a red herring.

Grin, I'll read more carefully before arguing next time. ;)

-Melvin

Reply via email to