Article View: comp.lang.misc
Article #2868C++ vs Objective-C
From: Darren New
Date: Fri, 01 Mar 1991 21:04
Date: Fri, 01 Mar 1991 21:04
25 lines
1939 bytes
1939 bytes
There is one advantage that Objective-C's binding seems to have over
C++'s, and that is for simulating multiple inheritance. For example, if
I have a window class that can handle Open, Close, and Scroll and I
have a text class that can handle Insert, Delete, and Search, I can
make a class in Objective-C that implements Open, Close, Scroll,
Insert, Delete and Search (possibly a subclass of either window or
text). I can do the same in C++, but as far as I understand it, I
cannot pass an instance of this new class to both routines that expect
windows and routines that expect texts. I'm not fully compentent in
C++, but as far as I understand the virtual functions are called via
offsets from a base into a table of function pointers; hence, all
pointers to Close in subclasses of window must be in the same place in
the table, and all pointers to Delete in subclasses of text must be in
the same place in the table. If these offsets conflict, I don't see
how one can pass my proposed new class to routines expecting windows or
texts. Since Objective-C binds (basically) on the name rather than
the offset of the function within the declaration, this can be done.
-- Darren
(Non constructive flames via email, please)
--
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages,
Formal Description Techniques (esp. Estelle), Coffee, Amigas -----
=+=+=+ Let GROPE be an N-tuple where ... +=+=+=
Technical Details
Message-ID:
<46266@nigel.ee.udel.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!sdd.hp.com!wuarchive!udel!ee.udel.eduShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!sdd.hp.com!wuarchive!udel!ee.udel.edu From: new@ee.udel.edu (Darren New) Newsgroups: comp.lang.misc Subject: C++ vs Objective-C Message-ID: <46266@nigel.ee.udel.edu> Date: 1 Mar 91 21:04:01 GMT Sender: usenet@ee.udel.edu Organization: University of Delaware Lines: 25 Nntp-Posting-Host: estelle.ee.udel.edu