• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Typecasting in Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Typecasting in Cocoa?


  • Subject: Re: Typecasting in Cocoa?
  • From: Thomas Lachand-Robert <email@hidden>
  • Date: Sat, 29 Dec 2001 12:43:47 +0100

Le samedi 29 dicembre 2001, ` 07:52 , Jim Correia a icrit :

At 11:37 PM -0700 12/28/01, Rosyna wrote:

zReal = 3.6*(double(x));

is perfectly valid C++ (see Page 131, Section 6.2.8 of the C++ Programming Language, Third Edition by Bjarne Stroustrup)

Ack, at 12/28/01, Jim Correia said:

Neither of the syntax examples you give above are valid C or C++.


Correct - C++ introduces function style casts and I overlooked that. (It isn't clear that this notation is extensible to pointer types (I don't have the Stroustrup book handy) - int * - without a typedef so perhaps you are better off using the familiar C syntax anyway.)

But since Objective-C is based on C, you need to use the C syntax, which is also portable to C++.


No you can use the C++ syntax, even classes, etc., if you like so, by using Obj-C++. It is just a matter of naming you file with extension ".mm"
instead of ".m" (use the Rename command of PB). The compiler will then recognize the file as Obj-C++. This permits, in particular, to declare a variable anywhere.

Be aware that compiling the same file with Obj-C++ is MUCH slower (ten or twenty times slower) though.

Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.


References: 
 >Re: Typecasting in Cocoa? (From: Jim Correia <email@hidden>)

  • Prev by Date: radio buttons
  • Next by Date: Re: radio buttons
  • Previous by thread: Re: Typecasting in Cocoa?
  • Next by thread: genstrings output
  • Index(es):
    • Date
    • Thread