Porting 'operator' to Obj-C

2008-09-26 Thread Alex Finkel
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; }

Re: Porting 'operator' to Obj-C

2008-09-26 Thread Dave DeLong
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/

Re: Porting 'operator' to Obj-C

2008-09-26 Thread Robert Claeson
On 26 Sep 2008, at 17:03, 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. snip - operator= is a normal assignment method that takes an NSArray as its argument. Something like the following

Re: Porting 'operator' to Obj-C

2008-09-26 Thread Alex Finkel
Thanks, but can you point me in the right direction. The code bellow does not build. Am I doing something wrong with the struct? typedef struct dbnames { short Handle; short Version; int Size; intNumEntries; char Name[ 32 ]; dbnames() :Handle(-1),

Re: Porting 'operator' to Obj-C

2008-09-26 Thread Jonathan Prescott
This is C++, not C. You need to be compiling this as Objective-C++, not Objective-C. Easiest way is to change the extension of the file from .m to .mm if you are using Xcode. As an aside, you do not need the typedef in C++. Simply declaring the struct (or class) is enough to declare the