Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!intercon!news From: amanda@mermaid.intercon.com (Amanda Walker) Newsgroups: comp.sys.mac.programmer Subject: Re: Multiple Inheritance for HandleObjects in C++ Message-ID: <268BA8DC.4CD4@intercon.com> Date: 29 Jun 90 19:15:39 GMT References: <15132@reed.UUCP> Sender: usenet@intercon.com (USENET The Magnificent) Reply-To: amanda@mermaid.intercon.com (Amanda Walker) Organization: InterCon Systems Corporation, Herndon, VA Lines: 25 In article <15132@reed.UUCP>, bowman@reed.UUCP (Eric Bowman) writes: > I've just discovered, to my horror, that you can't create HandleObjects > with multiple base classes in MPW C++. Are there any work arounds for this? > Anyone know why this is the case? The short answer is that HandleObjects, which were designed to allow compatibility with Object Pascal, are incapable of representing objects with multiple parent classes. The memory representation and method dispatching strategies in Object Pascal were only designed with single inheritance in mind. The longer answer is that C++ multiple inheritance depends on the ability to treat a pointer to a piece of an object as an object in its own right. This can be done with normal C "structs," but not with Macintosh handles. The only workaround I know of is to put a HandleObject into an instance variable of a "conventional" C++ object, with method wrappers to connect the two inheritance chains. This is kind of grody, and it still doesn't let you inherit from, say, several MacApp classes, but it's better than nothing... -- Amanda Walker InterCon Systems Corporation --