home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13480 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.4 KB  |  47 lines

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bu.edu!cvbnet!cvbnet.prime.com!skochhar
  2. From: skochhar@cvbnet.prime.com (Sandeep Kochhar x4618 5-2)
  3. Newsgroups: comp.lang.c++
  4. Subject: Nested Class constructors
  5. Message-ID: <3855@cvbnetPrime.COM>
  6. Date: 10 Sep 92 17:18:53 GMT
  7. Sender: postnews@cvbnetPrime.COM
  8. Distribution: usa
  9. Organization: Computervision
  10. Lines: 35
  11.  
  12. hi!
  13. Suppose I have a header file that contains:
  14.     class B { public: B(); };
  15.     class A { class B { public: B(); }
  16.           public: A(); };
  17.  
  18. In the implementation file, how to I declare and define the two constructors?
  19. For the global B class, I try
  20.     B::B() {...}
  21. and on my Sun C++ 2.1, I get:
  22.     "nest.c", line 26: error:  B() is not a member of B
  23.  
  24. For the nested B class, I tried
  25.     A::B::B() {...}
  26. but I got a message saying 
  27.     "nest.c", line 26: sorry, not implemented:  class names do not nest,
  28.     use typedef x::y y_in_x
  29. So, I tried,
  30.     typedef A::B BinA;
  31.     BinA::B() {...};
  32. but I got
  33.     "nest.c", line 27: undefined structure or union
  34.  
  35.  
  36. So, again, my question is:
  37. In the implementation file, how to I declare and define the two constructors?
  38.  
  39.  
  40. Thanks.
  41.  
  42. -- 
  43. Sandeep Kochhar
  44. Computervision, MS 5-2            email: skochhar@cvbnet.prime.com
  45. 14 Crosby Drive                   tel:   (617) 275-1800 x 4618          
  46. Bedford, MA 01730                 fax:   (617) 275-8506
  47.