• 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: Porting 'operator' to Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Porting 'operator' to Obj-C


  • Subject: Re: Porting 'operator' to Obj-C
  • From: Dave DeLong <email@hidden>
  • Date: Fri, 26 Sep 2008 09:07:43 -0600

Objective-C does not support operator overloading. [1, 2]

If you're looking to compare equality, the convention is to implement your own isEqual: method that returns a BOOL (YES or NO).

HTH,

Dave

[1]  http://borkwarellc.wordpress.com/2007/08/19/objective-c-is-stupid-but-i-still-like-it/
[2]  http://theocacao.com/comment/4600

On Sep 26, 2008, at 9:03 AM, Alex Finkel wrote:

Hi there.
I am in a process of porting some C++ code to ObjC. How to port the code
bellow (operators). Thanks.


typedef struct encoding_tag

{

   byte encodings[ 16 ];

   ushort count;


encoding_tag() { count = 0; }

   encoding_tag( encoding_tag& encoding ) { *this = encoding; }

   void operator = ( encoding_tag& encoding )

   {

       count = encoding.count;

       for ( int i = 0; i < count; i++ )

           encodings[i] = encoding.encodings[i];

   }

   bool operator == ( encoding_tag& cmp )

   {

       if ( count != cmp.count ) return false;

       return (*this <= cmp);

   }

   bool operator != ( encoding_tag& cmp )

   {

       return !(*this == cmp);

   }




} ENCODING; _______________________________________________

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

_______________________________________________

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


References: 
 >Porting 'operator' to Obj-C (From: "Alex Finkel" <email@hidden>)

  • Prev by Date: Porting 'operator' to Obj-C
  • Next by Date: Re: Fastest color detection in image?
  • Previous by thread: Porting 'operator' to Obj-C
  • Next by thread: Re: Porting 'operator' to Obj-C
  • Index(es):
    • Date
    • Thread