home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!ftpbox!motsrd!news
- From: shang@corp.mot.com (David (Lujun) Shang)
- Subject: Re: zero-length datatype
- Message-ID: <1992Sep14.141756.6514@cadsun.corp.mot.com>
- Sender: news@cadsun.corp.mot.com
- Reply-To: shang@corp.mot.com
- Organization: Motorola, Inc., Software Research and Development, Rolling Meadows, IL. 60008
- References: <TMB.92Sep12212903@arolla.idiap.ch>
- Distribution: comp
- Date: Mon, 14 Sep 92 14:17:56 GMT
- Lines: 35
-
- In article <TMB.92Sep12212903@arolla.idiap.ch> tmb@arolla.idiap.ch (Thomas M.
- Breuel) writes:
- > In article <23659@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
- >
- > In article <1992Sep11.185505.17536@cadsun.corp.mot.com> shang@corp.mot.com
- writes:
-
- > > But I don't see the reason why we can't have zero-size objects. Don't
- > > say that the standard explicitly says that. I want to know why it says
- > > that. So far, I haven't heard any convincing argument.
- >
- > I don't really know why. What I do know is that the presence of
- > that requirement in the C standard makes it hard to avoid the same
- > requirement in the C++ standard.
- >
- > Well, it might be good to remain compatible, in the sense that every
- > object that has non-zero size in ISO C also have a non-zero size in
- > C++. However, since there are no objects of type "void" (or of some
- > other, newly introduced, distinguished type with zero size) in ISO C,
- > there can't be any harm in letting objects of this new type have zero
- > size: the behavior of existing code would not be affected.
- >
-
- My question is that why the standard disallows zero-size object.
- Therefore, compatibility to the standard is not the reason.
-
- If we did not mix up class and struct, we could make C++
- compatible with C while letting empty class zero-sized but empty
- struct non-zero-sized.
-
- I'd like to have struct as a sealed class, i.e. it cannot be used to
- derived other classes or structures. If a struct is derived from an
- empty class, it's size becomes non-zero.
-
- David Shang
-