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]

does friend qualify as a forward decl?


I've been playing with GCC 4.0 recently and discovered that the code below
does not compile with Debian's 4.0.0-9 package.  The changelog for that
package says:

  * Update to CVS 20050522, taken from the gcc-4_0-branch.

Note that the code compiles fine with GCC 3.3.5 (Debian), GCC 4.0.0 (RHEL4),
Sun Workshop, and MSVC.

I'm not terribly familiar with the C++ standard on this point -- can someone
tell me whether this should compile or not and, if yes, will this be fixed
when 4.0.1 is released?

Thanks.

[please cc: me on replies]

// Begin source code
class B;

class Foo
{
friend class A;
friend class B;

public:
  Foo();
  virtual ~Foo();

  A* get_a() { return my_a; }
  B* get_b() { return my_b; }
  void set_a(A* t) { my_a = t; }
  void set_b(B* r) { my_b = r; }

protected:
  A* my_a;
  B* my_b;
};

-- 
Hippopotomonstrosesquippedaliophobia is the fear of long words

Attachment: pgp00000.pgp
Description: PGP signature


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