help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ 4: Unrecognised Friendship


From: JH Trauntvein
Subject: g++ 4: Unrecognised Friendship
Date: 3 Aug 2005 09:37:17 -0700
User-agent: G2/0.2

Consider the following example:

namespace n1
{
   class cn1_base;


   namespace n1_helpers
   {
      class helper1
      {
      private:
         int private_member;
         friend class cn1_base;
      };
   };


   class cn1_base
   {
   public:
      void foo()
      {
         n1_helpers::helper1 helper;
         helper.private_member = 1;
      }
   };
};


While this compiled with earlier versions of G++, G++ version 4.x fails
to compile this and gives the following message:

  'int n1::n1_helpers::helper1::private_member' is prviate within this
  context

Fortunately, I can work around this by changing the friend declaration
to the following:

  friend class n1::n1_base;

Is this a bug in the compiler or have I misunderstood something about
friendship declarations?

Regards,

Jon Trauntvein



reply via email to

[Prev in Thread] Current Thread [Next in Thread]