Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!unido!iraun1!shi_fuchs From: shi_fuchs@dkauni5t.bitnet (Harald Fuchs) Newsgroups: comp.lang.c++ Subject: Multiple inheritance problem Message-ID: Date: 15 Jun 89 13:00:43 GMT Sender: news@iraun1.ira.uka.de Organization: University Karlsruhe, Germany Lines: 44 I'm trying to write a simple tree class, but I can't get it working using G++ 1.35.0. It goes like that: class link { // Element of a doubly-linked list friend class list; friend class list_iterator; link* p; link* n; protected: link () { p = n = 0; } public: // ... }; class list: link { // Circular list: dummy header with forward and backward pointers public: list () { n = p = this; } // ... }; class list_iterator { list* l; link* x; public: list_iterator (list* a): l (a) { x = (link*) l; } link* operator() () { if (x) { x = x->n; if (x == l) x = 0; } return x; } void reset (list* a = 0) { if (a) l = a; x = (link*) l; } }; class tree: list, link { // A tree node has a list of sons (if not leaf) // and is an element of such a list (if not root) public: // ... }; A tree node must have TWO prev/next pointers to work. I think this is the case because I didn't declare the ``link'' base class virtual. So what's wrong here: G++ or my brain? -- Harald Fuchs shi_fuchs@dkauni5t.bitnet