home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!pipex!bnr.co.uk!bnrgate!scrumpy!bnrmtl@bnr.ca!john
- From: john@bnrmtl.bnr.ca (John Hickin)
- Subject: sizeof( data member )
- Message-ID: <1992Nov18.171207.16636@bnrmtl.bnr.ca>
- Sender: news@bnrmtl.bnr.ca (USENET NEWS KJ)
- Reply-To: bnrmtl!john@larry.mcrcim.mcgill.edu
- Organization: Bell Northern Research Montreal, Canada.
- Date: Wed, 18 Nov 92 17:12:07 GMT
- Lines: 22
-
- My compiler won't let me code like this:
-
- class Foo
- {
- char Data[ 200 ];
- public:
- static void foo( int );
- ...etc.
- };
-
- void Foo :: foo( int needed )
- {
- if ( !(needed <= sizeof(Foo::Data)) ) complain();
- }
-
- Of course I can use the enum { Size = 200 } to work around the problem.
- The question is, should the langauge allow you to take the size of a
- data member without having an object in hand?
-
- --
- John Hickin Bell-Northern Research, Montreal, Quebec
- (514) 765-8888 bnrmtl!john@larry.mcrcim.mcgill.edu
-