Path: utzoo!attcan!uunet!husc6!rutgers!gatech!gt-eedsp!baud From: baud@gt-eedsp.UUCP (Kurt Baudendistel) Newsgroups: comp.lang.c++ Subject: interlocking class definitions Keywords: c++, class, definitions, interlocking Message-ID: <382@gt-eedsp.UUCP> Date: 10 Aug 88 16:44:59 GMT Distribution: na Organization: School of Electrical Engineering, Ga. Tech, Atlanta, GA 30332 Lines: 51 suppose i wish to define two classes which work closely together, and that i wish to have member and friend functions in each class that return objects of the other type. further suppose that i wish to define constructors for each class that convert from one class to the other, and i want to use these constructors in the member and friend functions. this seems straightforward, and the following example illustrates it: class A { friend class B; ... A(B b); // body must be defined after class B // definition. } class B { friend class A; ... B(A a) { ... } // can be defined here since class A // is already defined. } inline A(B b) { ... } // body defined here my question about this example is whether there is another way to structure it so that the function definitions can be placed within the class definitions, rather than placing the function declarations within the class definitions and the function definitions after both class definitions as is done in here. i can't come up with a way that works with my g++ compiler. -- Kurt Baudendistel [GRA McClellan] Georgia Tech, School of Electrical Engineering, Atlanta, GA 30332 USENET: ...!{allegra,hplabs,ihnp4,ulysses}!gatech!gt-eedsp!$me INTERNET: $me@gteedsp.gatech.edu