Topic: No sealed record of birth parent (class) in C++?


Author: wkaras@yahoo.com
Date: Fri, 3 Nov 2006 18:01:54 CST
Raw View
Please look at this class definition:

class X
  {
  private:
    class A { protected: int a; };
  public:
    class B : private A
      {
      public:
        int x(void) { return(a); }
        int y(void) { return(sizeof(A)); }
        int z(void) { return(sizeof(X::A)); }
      };
  };

GNU C++ will compile this with no errors.  Green Hills C++ only
gives an error for the definition of the member function B::z() .
It makes sense to me that B can access the member a.
But I don't see why B should be able to access the name A
(that is, X::A).

Is this compliant with the Standard?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: AlbertoBarbati@libero.it (Alberto Ganesh Barbati)
Date: Sat, 4 Nov 2006 19:46:54 GMT
Raw View
wkaras@yahoo.com ha scritto:
> Please look at this class definition:
>
> class X
>   {
>   private:
>     class A { protected: int a; };
>   public:
>     class B : private A
>       {
>       public:
>         int x(void) { return(a); }
>         int y(void) { return(sizeof(A)); }
>         int z(void) { return(sizeof(X::A)); }
>       };
>   };
>
> GNU C++ will compile this with no errors.  Green Hills C++ only
> gives an error for the definition of the member function B::z() .
> It makes sense to me that B can access the member a.
> But I don't see why B should be able to access the name A
> (that is, X::A).
>
> Is this compliant with the Standard?

It's not compliant with current standard, but it's compliant with the
most recent draft, which includes the resolution of DR#45
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#45. See
also issue #494
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#494 (which
has status "ready").

Ganesh

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]