home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13615 < prev    next >
Encoding:
Text File  |  1992-09-14  |  2.0 KB  |  49 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: <1992Sep14.141756.6514@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: <TMB.92Sep12212903@arolla.idiap.ch>
  10. Distribution: comp
  11. Date: Mon, 14 Sep 92 14:17:56 GMT
  12. Lines: 35
  13.  
  14. In article <TMB.92Sep12212903@arolla.idiap.ch> tmb@arolla.idiap.ch (Thomas M.  
  15. Breuel) writes:
  16. > In article <23659@alice.att.com> ark@alice.att.com (Andrew Koenig) writes:
  17. >    In article <1992Sep11.185505.17536@cadsun.corp.mot.com> shang@corp.mot.com  
  18. writes:
  19.  
  20. >    > But I don't see the reason why we can't have zero-size objects. Don't 
  21. >    > say that the standard explicitly says that. I want to know why it says 
  22. >    > that. So far, I haven't heard any convincing argument.
  23. >    I don't really know why.  What I do know is that the presence of
  24. >    that requirement in the C standard makes it hard to avoid the same
  25. >    requirement in the C++ standard.
  26. > Well, it might be good to remain compatible, in the sense that every
  27. > object that has non-zero size in ISO C also have a non-zero size in
  28. > C++. However, since there are no objects of type "void" (or of some
  29. > other, newly introduced, distinguished type with zero size) in ISO C,
  30. > there can't be any harm in letting objects of this new type have zero
  31. > size: the behavior of existing code would not be affected.
  32.  
  33. My question is that why the standard disallows zero-size object. 
  34. Therefore, compatibility to the standard is not the reason.
  35.  
  36. If we did not mix up class and struct, we could make C++ 
  37. compatible with C while letting empty class zero-sized but empty 
  38. struct non-zero-sized.
  39.  
  40. I'd like to have struct as a sealed class, i.e. it cannot be used to 
  41. derived other classes or structures. If a struct is derived from an 
  42. empty class, it's size becomes non-zero.
  43.  
  44. David Shang
  45.