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: <1992Sep11.185505.17536@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: <23654@alice.att.com>
- Distribution: comp
- Date: Fri, 11 Sep 92 18:55:05 GMT
- Lines: 25
-
- In article <23654@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
- > In article <1992Sep10.181836.9929@cadsun.corp.mot.com> shang@corp.mot.com
- writes:
- >
- > > Note that g++ implements empty struct or class with size of zero.
- > > g++ also allows an array with zero number of member with size of zero.
- >
- > Unfortunately, this violates the ISO C standard, which explicitly says
- > that there are no zero-size objects.
-
- That is why ISO C standard does not allow empty structure and zero
- number of array. It prevents zero-size objects perfectly by langauge
- definition. But C++ is differrent. Since C++ allows empty class and
- an empty class can be instantiated, the zero-size object can only be
- prevented through the language implementation (In this sense, I should
- say the implementation somehow distorts the real meaning of an empty
- object!). If we realy want to prevent zero-size object, we should
- DISALLOW an empty class to instantiate object, i.e. an empty class
- should be an abstract class.
-
- 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.
-
- David Shang
-