Topic: Inherited nested classes?


Author: jane@mullian.ee.mu.OZ.AU (jane lynette cosham)
Date: 23 Aug 92 14:19:27 GMT
Raw View
I recently got a copy of MSC 7.0 and have come up aagainst a brick
wall in converting my BC 3.0 code so it is compatible with both
compilers.

The problem is that MSC 7.0 inherits nested classes and BC 3.0
doesn't.  MSC also takes note of access modifiers for nested classes.

For example :
 class A
 {
  public:
   class nested_A
   {
    ...
   };
  private:
   class nested_a2
   {
    ...
   };

   ...
 };


 class B : public A
 {
  ...
 };

Under MSC B::nested_A is a valid class. However B::nested_a2 is not
accesible outside of A.

Under BC neither class exists for B, and it is possible to declare a
variable of type A::nested_a2 anywhere.

It is my understanding that Borland's implementation is the norm.

The brick wall I came up with was that it is not possible to declare a
class nested within B of the same name as one nested in A - ie nested
classes cannot be hidden in the way functions can.  This is causing a
problem as I have a large amount of code where a nested 'helper' class
is used within an inheritance structure and is given the same name at
all levels.  This code needs major changes to cope with MSC 7.0.

I am writing this to get more information about nesting classes and
future compatibility.

Does anyone know if this issue has been considered for the standard
and what the outcome of any discussions was?  Also if the MSC
implementation is not standard, does anyone know if they intend to
continue with this in future versions?  Will future versions of MSC
allow you to hide nested classes?

In my opinion the inheritance of these classes is a useful property
however it causes hassles if the same name cannot be used in more than
one level of the class structure.

Thanks in advance for any comments.

Jane.