Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!orc!bbn.com!nic!hri!sparc17!roman From: roman@hri.com (Roman Budzianowski) Newsgroups: comp.lang.c++ Subject: Multiple Inheritance problem Message-ID: <1990Oct11.194148.14657@hri.com> Date: 11 Oct 90 19:41:48 GMT Sender: news@hri.com Reply-To: roman@hri.com (Roman Budzianowski) Organization: Horizon Research Lines: 101 I am having a hard time with multiple inheritance (cfront 2.0 on sparc). Basically, when in the constructor of a derived class, parts of the object are not initialized and as a result I get 'no mapping' errors when I call methods of this object. I can get it to work, but any minor change brings the problem again. Here is the class hierarchy: class Schema { public: virtual void f() {} ...a lot of virtuals } class WithSimpleSlot : virtual public Schema | class WithMethod : virtual public Schema {} { | void f() {} | } | ... class SystemSchema : public WithSimpleSlot, public WithMethod, public WithNoRelation {} class SchemaStream : public SystemSchema { ... SchemaStream() { f(); } // here is the problem } An instance of SchemaStream is created as a static object. It appears that the cfront actually creates three copies of Schema, and the methods called in the constructor of SchemaStream refer to a wrong copy. Can somebody help me ? Is this a cfront bug, or a problem with the design. Actually I got it to work, but it broke again when I tryed to make the destructor for Schema virtual. Below is an ouput from dbx, the 'no mapping' problem is due to myNode.ptr being null, which is not. (dbx) p *this *`extstream`StreamSchema::StreamSchema`this = { slotTable = 0x1aff20 [__vptr__14WithSimpleSlot = 0x1a278c] PSchema = 0x1a22e0 OWithMethod = { __vptr__10WithMethod = 0x1a25ac PSchema = 0x1a22e0 OSchema = { __W68__13SlotOwnerType = '\0' schemaNameID = (nil) myNode = { ptr = (nil) } state = 0 lock = '\0' __vptr__6Schema = (nil) } } OWithNoRelation = { __vptr__14WithNoRelation = 0x1a2500 PSchema = 0x1a22e0 OSchema = { __W68__13SlotOwnerType = '\0' schemaNameID = (nil) myNode = { ptr = (nil) } state = 0 lock = '\0' __vptr__6Schema = (nil) } } stream = 0x1a521c OSchema = { __W68__13SlotOwnerType = '\0' schemaNameID = 0x1affb8 myNode = { ptr = 0x1ad310 } state = 0 lock = '\0' __vptr__6Schema = 0x1a25e0 } } Thanks.