Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: mutual dependence of types Message-ID: <70068@microsoft.UUCP> Date: 16 Jan 91 20:12:19 GMT References: <35527@netnews.upenn.edu> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Distribution: usa Organization: Microsoft Corp., Redmond WA Lines: 63 In article <35527@netnews.upenn.edu> atteson@eniac.seas.upenn.edu (Kevin Atteson ) writes: |Is there any way to do the following in C++ and if so how? | |class A |{ | ... |public: | class B func1() | { | ... | } |}; | |class B |{ | ... |public: | class A func2() | { | ... | } |}; | |I don't want to return pointers to the classes. |I am a recent initiate to C++ and so I apologize if the question is obvious. |Please send responses directly to me and post them if you think it useful. No apologies necessary -- the number of C++ users continues to double about every nine months. Thus most C++ users are neophytes, and the few people who have been programming in C++ for a more than a year get to play "expert". And thus, its important that these fundamental questions continue to be asked and answered. Consider: extern "C" { #include } class A { public: A() { printf("making an A\t"); }; class B func1(); }; class B { public: B() { printf("making a B\t"); }; class A func2(); }; B A::func1() { printf("\nIn A::func1 :"); return B(); } A B::func2() { printf("\nIn B::func2 :"); return A(); } main() { A a; B b; a.func1(); b.func2(); }