home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16569 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.3 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gumby!wupost!cs.uiuc.edu!sparc0b!pjl
  3. From: pjl@cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Help with nested class and constructor
  5. Message-ID: <Bxz448.4nv@cs.uiuc.edu>
  6. Sender: news@cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <Bxyxrv.EJ3@news.cso.uiuc.edu>
  9. Distribution: usa
  10. Date: Thu, 19 Nov 1992 17:19:20 GMT
  11. Lines: 31
  12.  
  13. In <Bxyxrv.EJ3@news.cso.uiuc.edu> macg9505@uxa.cso.uiuc.edu (Michael Alan Corn) writes:
  14.  
  15.  
  16. >I could use a little help on nested classes:
  17. >      I would like to include one of Borlands Array classes in another class,
  18. >in the private data section, but since the constructor requires an int to
  19. >initialize the class, I'm not sure how or where to give it the value:
  20.  
  21. >class foo {
  22. >      private:
  23. >      Array myarray(10); ///this doesn't work, the compiler chokes
  24.  
  25.  
  26. *****>    foo::foo() : myarray(10) {/*...*/}
  27.  
  28.     Look up mem-initializer in the C++ you have.
  29.  
  30. >so I've tried this, which seems to work
  31.  
  32. >class foo {
  33. >      private:
  34. >      void *myarray;
  35.  
  36. *****>    Why void*?  How about Array*?  Of course, if you do the first 
  37.     thing above, you needn't do anything else.
  38.  
  39.     [remainder elided]
  40. -- 
  41.     - Paul J. Lucas                University of Illinois    
  42.       AT&T Bell Laboratories        at Urbana-Champaign
  43.       Naperville, IL            pjl@cs.uiuc.edu
  44.