home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13722 < prev    next >
Encoding:
Text File  |  1992-09-15  |  959 b   |  45 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!decwrl!pa.dec.com!brister
  3. From: brister@decwrl.dec.com (James Brister)
  4. Subject: consts inside a class?
  5. Message-ID: <BRISTER.92Sep15185309@tirade.decwrl.dec.com>
  6. Sender: news@PA.dec.com (News)
  7. Organization: DEC Western Software Lab
  8. Date: 15 Sep 92 18:53:09
  9. Lines: 34
  10.  
  11. I've been putting lines like
  12.  
  13.     const int maxLineSize = 1024 ;
  14.  
  15. in global scope, but would rather have it inside the class declaration.
  16. However, my compiler chokes on 
  17.  
  18.     class A 
  19.     {
  20.       public:
  21.     const int foo = 10 ;
  22.     int a ;
  23.     };
  24.  
  25.     main (int argc, char **argv) 
  26.     {
  27.     A z ;
  28.  
  29.     z.a = A::foo ;
  30.     }
  31.  
  32. with:
  33.  
  34.     test.C:4: error: Invalid pure specifier.
  35.  
  36. so I suppose this way isn't legal. Is there a legal way to do this, or am I
  37. stuck with my current method?
  38.  
  39. Thanks
  40.  
  41. James
  42. --
  43. James Brister                                           brister@wsl.pa.dec.com
  44. DEC Western Software Lab., Palo Alto, CA                        decwrl!brister
  45.