Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!ditka!comeau From: comeau@ditka.Chicago.COM (Greg Comeau) Newsgroups: comp.lang.c++ Subject: Re: Multiple inheritence problem Message-ID: <38574@ditka.Chicago.COM> Date: 10 May 91 13:46:55 GMT References: <74462@brunix.UUCP> Sender: comeau@ditka.Chicago.COM (Greg Comeau) Reply-To: comeau@csanta.attmail.com (Greg Comeau) Organization: Comeau Computing Lines: 35 In article joshua@paul.rutgers.edu (Josh Mittleman) writes: >class Object { public: virtual void Draw() = 0; virtual void Update() = 0; > virtual Object* Dup() = 0; }; >class Line: public virtual Object { public: void Draw(); }; >class Dependent: public virtual Object { public: void Update(); }; >class DependentLine: public Line, public Dependent { >public: Object *Dup() { return new DependentLine; }; // error here >}; >I can't find anything in ARM which covers this problem specifically, but >obviously what's happening is that one or both of these is being inherited >as pure virtual, and so DependentLine is considered abstract. Exactly. Check out something like page 214 of the ARM where we should be told that pure virtual are inherited as pure virtuals. What's ended up having then is that Line is abstract since it doesn't redefine Update or Dup. Dependent is abstract since it doesn't redefine Draw or Dup. And since Dependentline is based on Abstract classes containing pure virtuals, it too must be abstract since it doesn't redefine Draw or Update! (Are we having fun yet?). >I guess this is consistent with the way that C++ deal with other ambiguities: >Don't flag an error until the ambiguity is actually invoked. Not at all. Since you can't create an instance of an abstract class, there was nothing wrong until the new was seen. Having a hierarchy of abstract classes is sometimes a desirable thing. It's all fully in accord to C++'s typing/safety philosophy as well. - Greg -- Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 Producers of Comeau C++ 2.1 Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421 Voice:718-945-0009 / Fax:718-441-2310