home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13551 < prev    next >
Encoding:
Text File  |  1992-09-11  |  1.6 KB  |  39 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!ftpbox!motsrd!news
  3. From: shang@corp.mot.com (David (Lujun) Shang)
  4. Subject: Re: zero-length datatype
  5. Message-ID: <1992Sep11.185505.17536@cadsun.corp.mot.com>
  6. Sender: news@cadsun.corp.mot.com
  7. Reply-To: shang@corp.mot.com
  8. Organization: Motorola, Inc., Software Research and Development, Rolling Meadows, IL. 60008
  9. References: <23654@alice.att.com>
  10. Distribution: comp
  11. Date: Fri, 11 Sep 92 18:55:05 GMT
  12. Lines: 25
  13.  
  14. In article <23654@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
  15. > In article <1992Sep10.181836.9929@cadsun.corp.mot.com> shang@corp.mot.com  
  16. writes:
  17. > > Note that g++ implements empty struct or class with size of zero. 
  18. > > g++ also allows an array with zero number of member with size of zero.
  19. > Unfortunately, this violates the ISO C standard, which explicitly says
  20. > that there are no zero-size objects.
  21.  
  22. That is why ISO C standard does not allow empty structure and zero 
  23. number of array. It prevents zero-size objects perfectly by langauge 
  24. definition. But C++ is differrent. Since C++ allows empty class and 
  25. an empty class can be instantiated, the zero-size object can only be 
  26. prevented through the language implementation (In this sense, I should 
  27. say the implementation somehow distorts the real meaning of an empty 
  28. object!). If we realy want to prevent zero-size object, we should 
  29. DISALLOW an empty class to instantiate object, i.e. an empty class 
  30. should be an abstract class.
  31.  
  32. But I don't see the reason why we can't have zero-size objects. Don't 
  33. say that the standard explicitly says that. I want to know why it says 
  34. that. So far, I haven't heard any convincing argument.
  35.  
  36. David Shang
  37.