home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12773 < prev    next >
Encoding:
Text File  |  1992-08-23  |  2.2 KB  |  76 lines

  1. Xref: sparky comp.lang.c++:12773 comp.std.c++:1107
  2. Path: sparky!uunet!pmafire!news.dell.com!swrinde!mips!mips!munnari.oz.au!cs.mu.OZ.AU!jane
  3. From: jane@mullian.ee.mu.OZ.AU (jane lynette cosham)
  4. Newsgroups: comp.lang.c++,comp.std.c++
  5. Subject: Inherited nested classes?
  6. Summary: MSC 7.0 & BC 3.0 - differ about nested classes
  7. Keywords: nested classes, inheritance
  8. Message-ID: <jane.714579567@munagin>
  9. Date: 23 Aug 92 14:19:27 GMT
  10. Sender: news@cs.mu.OZ.AU
  11. Organization: Computer Science, University of Melbourne, Australia
  12. Lines: 62
  13.  
  14.  
  15. I recently got a copy of MSC 7.0 and have come up aagainst a brick
  16. wall in converting my BC 3.0 code so it is compatible with both
  17. compilers.
  18.  
  19. The problem is that MSC 7.0 inherits nested classes and BC 3.0
  20. doesn't.  MSC also takes note of access modifiers for nested classes.
  21.  
  22. For example :
  23.     class A
  24.     {
  25.         public:
  26.             class nested_A
  27.             {
  28.                 ...
  29.             };
  30.         private:
  31.             class nested_a2
  32.             {
  33.                 ...
  34.             };
  35.             
  36.             ...
  37.     };
  38.  
  39.  
  40.     class B : public A
  41.     {
  42.         ...
  43.     };
  44.  
  45. Under MSC B::nested_A is a valid class. However B::nested_a2 is not
  46. accesible outside of A.
  47.  
  48. Under BC neither class exists for B, and it is possible to declare a
  49. variable of type A::nested_a2 anywhere.
  50.  
  51. It is my understanding that Borland's implementation is the norm.
  52.  
  53. The brick wall I came up with was that it is not possible to declare a
  54. class nested within B of the same name as one nested in A - ie nested
  55. classes cannot be hidden in the way functions can.  This is causing a
  56. problem as I have a large amount of code where a nested 'helper' class
  57. is used within an inheritance structure and is given the same name at
  58. all levels.  This code needs major changes to cope with MSC 7.0.
  59.  
  60. I am writing this to get more information about nesting classes and
  61. future compatibility.  
  62.  
  63. Does anyone know if this issue has been considered for the standard
  64. and what the outcome of any discussions was?  Also if the MSC
  65. implementation is not standard, does anyone know if they intend to
  66. continue with this in future versions?  Will future versions of MSC
  67. allow you to hide nested classes?
  68.  
  69. In my opinion the inheritance of these classes is a useful property
  70. however it causes hassles if the same name cannot be used in more than
  71. one level of the class structure.
  72.  
  73. Thanks in advance for any comments.
  74.  
  75. Jane.
  76.