Re: A simple Objective-C question
Re: A simple Objective-C question
- Subject: Re: A simple Objective-C question
- From: "Kevin Dixon" <email@hidden>
- Date: Thu, 10 Apr 2008 15:43:23 -0400 (EDT)
- Importance: Normal
While you can use Objective-C++, the main reservation is you cannot
combine the semantics of the two languages. Objects of each language need
to maintain clear divison, and only be created and deleted according to
their native language.
So C++ objects use new/delete and Objective-C objects must use alloc/release
-Kevin
> Mr. Krishna:
>
> I, too am new to Objective-C, but in the two books I have been
> studying on the language, they both make the point that Objective-C
> plays nicely with both C and C++. Could you simply write a standard C++
> class and instantiate it the same way one does with other C++ classes
> (i.e. by declaring it, or by using the new operator)?
>
> R,
> John
>
> -----Original Message-----
> From: cocoa-dev-bounces+john.darnell=email@hidden
> [mailto:cocoa-dev-bounces+john.darnell=email@hidden] On
> Behalf Of Rama Krishna
> Sent: Thursday, April 10, 2008 1:22 PM
> To: email@hidden
> Subject: A simple Objective-C question
>
> I am new to Objective-C but I have done C++/C#/Java work. I have been
> doing
> some experiments to understand how the language works. I found that it
> is
> not necessary for an Objective-C class to derive from Object. I was able
> to
> create a class which did not derive from Object contrary to my
> assumption
> that all Objective-C classes implicitly derive from Object (such as in
> C# or
> Java).
>
>
>
> However, such a class has a problem. It cannot be allocated or
> initialized.
> Because it can never get the alloc message as the alloc message is
> declared
> in the Object class. My question ,therefore, is how can such classes be
> instantiated. Is there a library function for that? Surely, the standard
> alloc function must be using such a function. Or should I just derive
> all
> classes from Object.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden