home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16520 < prev    next >
Encoding:
Text File  |  1992-11-18  |  976 b   |  34 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!pipex!bnr.co.uk!bnrgate!scrumpy!bnrmtl@bnr.ca!john
  3. From: john@bnrmtl.bnr.ca (John Hickin)
  4. Subject:  sizeof( data member )
  5. Message-ID: <1992Nov18.171207.16636@bnrmtl.bnr.ca>
  6. Sender: news@bnrmtl.bnr.ca (USENET NEWS KJ)
  7. Reply-To: bnrmtl!john@larry.mcrcim.mcgill.edu
  8. Organization: Bell Northern Research Montreal, Canada.
  9. Date: Wed, 18 Nov 92 17:12:07 GMT
  10. Lines: 22
  11.  
  12. My compiler won't let me code like this:
  13.  
  14.     class Foo
  15.     {
  16.             char Data[ 200 ];
  17.     public:
  18.         static void foo( int );
  19.         ...etc.
  20.     };
  21.  
  22.     void Foo :: foo( int needed )
  23.     {
  24.         if ( !(needed <= sizeof(Foo::Data)) ) complain();
  25.     }
  26.  
  27. Of course I can use the enum { Size = 200 } to work around the problem.
  28. The question is, should the langauge allow you to take the size of a
  29. data member without having an object in hand?
  30.  
  31. -- 
  32. John Hickin      Bell-Northern Research, Montreal, Quebec
  33. (514) 765-8888   bnrmtl!john@larry.mcrcim.mcgill.edu
  34.