🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by europa!ark Tue, 21 Mar 1989 02:23
(none)
#387
Author: europa!ark
Date: Tue, 21 Mar 1989 02:23
20 lines
1278 bytes
One difficulty has not yet been mentioned in making sizeof
respect virtual functions.  Suppose D is derived from B and
bp is a B*.  Then bp can `really' be pointing either to a
B or to a D.  One might think that sizeof(*bp) should be
able to tell which.

However, the C language definition says that if the argument
of sizeof() is an expression, that expression is not evaluated!
It is obviously impossible to tell whether bp points at a B or
a D without evaluating it.

You might think it doesn't really matter -- after all, how can
it hurt to evaluate an expression like *bp to figure out the value
of sizeof(*bp)?  But what about sizeof(f()), where f is a function
returning a B*?  You can't call f, or it wouldn't be C -- and
it would be very sleazy to say that sizeof evaluates its argument
if virtual functions are involved but not otherwise.

No, it seems that this kind of facility must be named something
else.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads