Path: utzoo!attcan!uunet!husc6!uwvax!dogie!uwmcsd1!leah!bingvaxu!sunybcs!sher
From: sher@sunybcs.uucp (David Sher)
Newsgroups: comp.lang.c++
Subject: Re: classes with no data members (Example)
Keywords: sizeof,empty classes,new
Message-ID: <12193@sunybcs.UUCP>
Date: 24 Jun 88 15:52:02 GMT
References: <464@polari.UUCP> <7943@alice.UUCP> <470@polari.UUCP> <10399@sol.ARPA> <18223@cornell.UUCP> <423@bloom.UUCP> <5103@ihlpf.ATT.COM>
Sender: nobody@sunybcs.UUCP
Reply-To: sher@wolf.UUCP (David Sher)
Organization: SUNY/Buffalo Computer Science
Lines: 25

The key to why you might want to take the address of empty classes:
What if the empty class has a subclass that is not empty.  For example:
class Type {
public:
    char * question() { return "Why?" }
    };

class Wierd : Type {
    int i; ...
    };

Now lets say Type was a container type for a large variety of subtypes
that only share a few properties (inherited from type) such as the
question function above.  This is about the only reason you'd want an
empty class in the first place, as a source of inheritted functions.
Then say you are manipulating an array of Type.  You definitely want
them to compare unequal since some of them will have content.  Also
otherwise you break the semantics of arrays in C as another poster
pointed out.  I can not see where you gain by having their addresses
compare equal, except to save marginal amounts of space or to simplify
the compiler (how does it simplify the compiler?).  I see only problems
by making pointers to empty objects null.
-David Sher
ARPA: sher@cs.buffalo.edu	BITNET: sher@sunybcs
UUCP: {rutgers,ames,boulder,decvax}!sunybcs!sher