Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!jarthur!uci-ics!rfg From: rfg@ics.uci.edu (Ronald Guilmette) Newsgroups: comp.lang.c++ Subject: Re: how do you define classes that refer to each other ??? Message-ID: <261087B8.2418@paris.ics.uci.edu> Date: 28 Mar 90 09:45:28 GMT References: <1990Mar26.115427.14031@newcastle.ac.uk> Reply-To: rfg@ics.uci.edu (Ronald Guilmette) Organization: UC Irvine Department of ICS Lines: 45 In article <1990Mar26.115427.14031@newcastle.ac.uk> Lindsay.Marshall@newcastle.ac.uk (Lindsay F. Marshall) writes: >Just to be awkward, can anybody suggest a legal way of doing the >following :- > > class B; > > class A > { > public: > A(); > > void fa(void (*B::fb)()); > }; > > class B > { > public: > B(); > > void fb(void (*A::fa)()); > }; > >CC 2.0 gives syntax errors when you try to do this... As well it should. It seems that you have the *'s in the wrong places. Try using these function declarations instead: void fa(void (B::*fb)()); void fb (void (A::*fa)()); >g++ 1.37.1 gives reasonable error messages. I'd like to know how you define "reasonable". g++ certainly doesn't allow such things, either when they are written with correct syntax or not. When written incorrectly (as shown in your example) I have no idea what g++ will say. When written with correct syntax, g++ will probably just say "syntax error". // Ron Guilmette (rfg@ics.uci.edu) // C++ Entomologist // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.