Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!tut!santra!santra!ahuttune From: ahuttune@niksula.hut.fi (Ari Juhani Huttunen) Newsgroups: comp.lang.c++ Subject: Multiple inheritance: should this work? Message-ID: Date: 27 May 90 11:39:54 GMT Sender: news@santra.uucp (Cnews - USENET news system) Distribution: comp Organization: Helsinki University of Technology, Finland Lines: 47 The following program compiles using g++ 1.36 but core dumps. The idea is to have several classes accessed through a base-class pointer. The base class defines a procedure "foo" that is re-defined in every child class using multiple inheritance. If this is not the right way, I would like to hear a better one. Please send replies by mail because I won't be able to read them until these news have expired.. ------clip-------clip-----clip----- #include class foo_class1 { public: foo() {printf("A procedure..(1)\n");} }; class foo_class2 { public: foo() {printf("A procedure..(2)\n");} }; class base_class { public: virtual foo() = 0; }; class derived_class1: public base_class, public foo_class1 { }; class derived_class2: public base_class, public foo_class2 { }; main() { base_class *tmp1 = new derived_class1; base_class *tmp2 = new derived_class2; tmp1->foo(); tmp2->foo(); } -----clip----clip----------clip--- -- ___ ___ ___ ___ ___ ___ ___ ___ ___ Fair is foul, __I I__I I__I I__I I__I I__I I__I I__I I__I I and foul is fair: Ari Huttunen (ahuttune@niksula.hut.fi) I Hover through the fog ____________________________________________I and filthy air.