Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!rice!uw-beaver!ssc-vax!bcsaic!mgates From: mgates@entiat.boeing.com (Michael Gates) Newsgroups: comp.lang.c++ Subject: Re: Multiple Inheritance Problem Message-ID: Date: 15 May 91 18:21:33 GMT References: <74462@brunix.UUCP> <2153@godzilla.tcs.com> Sender: nntp@bcsaic.UUCP Organization: Boeing Computer Services, Bellevue, WA Lines: 51 In-reply-to: robert@kohlrabi.tcs.com's message of 6 May 91 19:06:41 GMT >In article <2153@godzilla.tcs.com> robert@kohlrabi.tcs.com (Robert Blumen) writes: > In article <74462@brunix.UUCP>, thc@cs.brown.edu (Thomas Colthurst) writes: > |> class Object { > |> public: > |> Object(); > |> ~Object(); > |> virtual void Draw() = 0; > |> virtual void Update() = 0; > |> virtual Object* Dup() = 0; > |> } > |> class Line: public virtual Object { > |> public: > |> Line(); > |> ~Line(); > |> void Draw(); > |> } > |> class Dependent: public virtual Object { > |> public: > |> Dependent(); > |> ~Dependent(); > |> void Update(); > |> } > |> class DependentLine : public Line, public Dependent { > |> public: > |> DependentLine(); > |> ~DependentLine(); > |> Object *Dup() { return( (new DependentLine) ); }; // error here > |> } > |> Sun CC version 2.1 gives me an error on the line > |> marked above, saying > |> "./ChildrenObjs.H", line 30: error: `new' of abstract class DependentLine > > For one thing, a class that inherits a pure virtual function must define it > or redefine it to be pure virtual. G++ 1.39 compiles this with no trouble at all, which is correct. For each pure virtual function, there is a path from DependentLine to Object which defines that function. The ARM section 10.1.1 addresses this issue under the topic of name dominance. Page 205: A name B::f dominates a name A::f if its class B has A as a base. If a name dominates another no ambiguity exists between the two; the dominant name is used when there is a choice. (Followed by example) Here Line::Draw dominates the Object::Draw that is also inherited by DependentLine. Also Dependent::Update dominates Object::Update. -- et tu mgates?