Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!ukc!edcastle!ecsv38 From: ecsv38@castle.ed.ac.uk (S Manoharan) Newsgroups: comp.lang.c++ Subject: Scope of friendship Message-ID: <6142@castle.ed.ac.uk> Date: 5 Sep 90 14:54:38 GMT Sender: ecsv38@castle.ed.ac.uk Reply-To: sam@lfcs.ed.ac.uk Organization: Dept of Computer Science, University of Edinburgh Lines: 31 Can a derived class automatically be a friend of a class whose friend is the base class? class Z { friend class Base; private: int foo; }; class Base { private: Z bar; public: void testB() { bar.foo = 1; } }; class Derived : public Base { private: Z bar; public: void testD() { bar.foo = 1; } }; Specifically, Base can access Z::foo; but, why shouldn't Derived be permitted to access Z::foo? Grrr! g++ (1.37.1) does not allow Z::foo to be accessed by Derived. Thanks for your attention. Manoharan.