This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Member class access to private members of enclosing class


Hi there,

I'd like someone to please clarify the following:

http://mail.gnu.org/pipermail/gnats-prs/2001-July/000339.html

I've found numerous references to this but I haven't found something that
definitively gives a conclusion.  Right now g++ acts the way I'd expect it
but Stroustroup's book directly contradicts it:

The way I look at it, is that a class defined within another class is a
*member* of that class, and as in the case for function members gains access
to all the private/protected members of the surrounding class.

ie.

class Frog
{
    int x, y;

    class Blob
    {
        void Func(  Frog& _Frog )
        {
            _Frog.x = 10;
            _Frog.y = 20;
        }
    };
    ...
};

G++ (3.1 beta) compiles this with no problems, and I think it should work,
but I find conflicting information on the web and in "The C++ Programming
Language 3rd edition".

Regards

Dylan Cuthbert
http://www.q-games.com/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]