baud@gt-eedsp.UUCP (Kurt Baudendistel) (08/10/88)
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; <data component definitions> ... A(B b); // body must be defined after class B // definition. <A function declarations> } class B { friend class A; <data component definitions> ... B(A a) { ... } // can be defined here since class A // is already defined. <B function declarations> } inline A(B b) { ... } // body defined here <A function definitions> <B functions definitions> 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