ahuttune@niksula.hut.fi (Ari Juhani Huttunen) (05/27/90)
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 <stdio.h> 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. <Macbeth>