Search code examples
c++iphonecobjective-cobjective-c++

C vs C++ (Objective-C vs Objective-C++) for iPhone


I would like to create a portable library for iPhone, that also could be used for other platforms.

My question is the fallowing:

Does anyone knows what is the best to be used on the iPhone: Objective-C or Objective-C++? Does it works with C++ the same way as Objective-C with C or not?

Reasons: Objective-C is a superset of C, but Objective-C++ is not a superset of C++.

Thanks in advance!

UPDATE: What about memory usage, speed in the same implementation of an use case?


Solution

  • They're not really different languages. Objective-C++ is just Objective-C with slightly limited support for including C++ code. Objective-C is the standard dialect, but if you need to work with C++, there's no reason not to use it. AFAIK, the biggest practical difference (aside from allowing use of different libraries) is that Objective-C++ seems to compile a bit slower. Just be sure to read up on it first if you do decide to go that route, because the merging of C++ and Objective-C is not 100% seamless.