Article View: comp.lang.objective-c
Article #389Re: Objective-C and C++ (at the same time)
From: Paul Kunz
Date: Thu, 24 Feb 1994 20:56
Date: Thu, 24 Feb 1994 20:56
57 lines
2898 bytes
2898 bytes
In article <CLqL0u.9KL@cdsmail.cdc.com> Ben Youngdahl
<Ben.Youngdahl@cdc.com> writes:
> This sounds interesting... is this Objective-C++ only available to NeXT
> users?
As far as I can tell GNU gcc does not yet support Objective-C++,
althought it accepts the flag "-lang-objc++". So that leaves only the NeXT
version of gcc
> Does it allow multiple inheritence?
No, because Objective-C doesn't.
> Can a class have one method written in Objective-C, and another
> written in C++?
No.
> How freely can you mix the code?
>
Here are some examples...
// init method in SimpleCalc.C; an Objective-C++ class
- init
{
cplus_object = new CalcEngine; // new is a keyword in C++.
previousAction = 0;
return self;
}
// User pressed the Clear All key.
- clearAllKey:sender
{
cplus_object->clear(); // invoke C++ member function
[self registerAction:0];
return [self clearKey:sender];
}
// snipet
[display setDoubleValue:
cplus_object->equalsKey([display doubleValue])];
// send display doubleValue message, use return value as argument to C++
// member function; take return value as argument to setDoubleValue method.
> Please pardon my struggling to remember objective-C syntax, but I seem to
> recall that one of the best things about Objective-C was the run-time
> binding
> of calling methods. I.e., you want to call the method "foo" for an
> object
> "bar", you'd do: [bar "foo"] or something like that, and if the object
> "bar"
It's [bar foo]
> didn't have a "foo" method, ... no harm done. Am I correct?
>
No, you get a run-time error saying bar does not implement foo.
--
Paul F. Kunz Paul_Kunz@slac.stanford.edu (NeXT mail ok)
Stanford Linear Accelerator Center, Stanford University
Voice: (415) 926-2884 (NeXT) Fax: (415) 926-3587
Technical Details
Message-ID:
<CLqy63.I3E@unixhub.SLAC.Stanford.EDU>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!netnews.upenn.edu!dsinc!ub!news.kei.com!sol.ctr.columbia.edu!howland.reston.ans.net!agate!headwall.Stanford.EDU!unixhub!newsReferences:
<CLqL0u.9KL@cdsmail.cdc.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10ba33,bfb0af118239035a X-Google-Attributes: gid10ba33,public X-Google-Thread: f9256,bfb0af118239035a X-Google-Attributes: gidf9256,public X-Google-Thread: 109fba,bfb0af118239035a X-Google-Attributes: gid109fba,public X-Google-Thread: 1111a3,bfb0af118239035a X-Google-Attributes: gid1111a3,public X-Google-ArrivalTime: 1994-02-24 12:56:26 PST Newsgroups: comp.lang.objective-c,comp.lang.c++,comp.sys.next.programmer,gnu.g++.help Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!netnews.upenn.edu!dsinc!ub!news.kei.com!sol.ctr.columbia.edu!howland.reston.ans.net!agate!headwall.Stanford.EDU!unixhub!news From: Paul_Kunz@slac.stanford.edu (Paul Kunz) Subject: Re: Objective-C and C++ (at the same time) Message-ID: <CLqy63.I3E@unixhub.SLAC.Stanford.EDU> Sender: news@unixhub.SLAC.Stanford.EDU Reply-To: Paul_Kunz@slac.stanford.edu Organization: Stanford Linear Accelerator Center References: <CLqL0u.9KL@cdsmail.cdc.com> Date: Thu, 24 Feb 1994 20:56:26 GMT Lines: 57