🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #684

Re: friend declaration scope

#684
From: Arthur Sombrito
Date: Thu, 08 Oct 1992 07:20
46 lines
1919 bytes
--


Hi,

I'd like to add something to my original post.

One ambiguity is regarding the visibility and scope of a friend.
ARM p. 248 states that the name of a friend is not in the scope of 
the class.  I would assume that this refers to friend functions only.
Otherwise a nested class can't be made a friend. 

ARM p. 250 states that an undeclared class or function name is
entered in the same scope as the name of the class containing
the friend declaration. It would then mean that if a nested class 
exists with the same name as the friend class, then the friend class 
refers to the nested class. Otherwise if no class exists by that 
friend name, then it is a forward declaration of a class which is 
in the same scope as the class containing the friend declaration.

Given:

  short f() {}
  class C { protected: enum A {}; class F {};};
  class D {};
  class F {};
  class B : public C
  {  
    long f() {}
    friend short f(); // ok? Does it refer to ::f()?

    friend class F;   // ok - refers to C::F 
    friend class A;   // ok - forward declare a ::A class

    class D {};
    friend class D;   // Does it refer to B::D?

    enum C {};
    friend class C;   // Is ::C visible?
                      // If my interpretation is correct, ::C is still
                      // visible since no class exists within class B
                      // definition
  };

Many thanks.
Technical Details
Message-ID: <1992Oct8.072051.26029@nuscc.nus.sg>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!nuscc!arthur
References: <1992Oct7.094248.177@nuscc.nus.sg>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!nuscc!arthur
From: arthur@solomon.technet.sg (Arthur Sombrito)
Subject: Re: friend declaration scope
Message-ID: <1992Oct8.072051.26029@nuscc.nus.sg>
Sender: usenet@nuscc.nus.sg
Organization: National University of Singapore
X-Newsreader: TIN [version 1.1 PL6]
References: <1992Oct7.094248.177@nuscc.nus.sg>
Date: Thu, 8 Oct 1992 07:20:51 GMT
Lines: 49