12

I know there are a lot of "Objective-C for the C++ programmer" information out there and it could be used the other way around. I'm just curious if there is anyone who has knowledge about a "native" "C++ for the Objective-C programmer" tutorial/book?

I'm actually looking to work in C++ in parts of a upcoming iOS project. Basically I need to do a lot of wrappers around C++ code.

(I do know that they can co-exist and that Obj-C is a subset of C, just like C++, however different reasons I would like to gain more knowledge into C++. Coming from a Obj-C background I just ask for some guidance on the matter.)

sebrock
  • 1,214
  • 2
  • 15
  • 32
  • So what is the question? If we know a programmer? – rid Nov 05 '11 at 14:35
  • 2
    I think he is looking for a book or tutorial that will teach C++ to an Objective-C developer. – fredoverflow Nov 05 '11 at 14:39
  • 1
    *I need to do a lot of wrappers around C++ code.* you do know that C++ and ObjC can coexist? if you already have working C++, you can use Objective-C++. I mention this because many people don't know about this *and* because they think that an extensive objc abstraction layer will be easy and somehow better, when it's often a waste of time to wrap and abstract the C++ unnecessarily ('a little' is often necessary). Nevertheless, you will need some time with C++ to use it on your project. – justin Nov 05 '11 at 14:39
  • I do know this. However in this particular project I need to do native obj-c wrappers. Also I'm looking to gain more knowledge of C++, coming from Obj-C I thought this would be a good start. I've fixed my question, sorry for being unclear. – sebrock Nov 05 '11 at 14:45
  • 2
    Just go for a [proper C++ book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)? – Bart Nov 05 '11 at 14:50
  • @sebrock No problem. I know of no such resource, but there are many C++ books for C programmers. If you get no helpful answers, you may want to try Accelerated C++ by Koenig and Moo. Once you have that, resources which teach you to use ObjC++ (and ultimately create good wrappers) is scarce. Learning C++ will take much longer than ObjC. – justin Nov 05 '11 at 14:54
  • 8
    i don't understand why people are downvoting this, and voting to close it as 'not a real question'. the question makes sense to me 'as-is'. – justin Nov 05 '11 at 15:05
  • 1
    _I do know … Obj-C is a subset of C, just like C++_. I've read that Obj-c is a strict superset of C, but C++ isn't. Also, I would also benefit from knowing about a good C++ book for people with a C/Obj-C background. Template code is almost unreadable to me. – SSteve Nov 05 '11 at 16:27

2 Answers2

4

Take a look at Pierre Chatelier's comparison of C++ and Objective-C.

This document is designed to act as a bridge between C++ and Objective-C.

http://pierre.chachatelier.fr/programmation/fichiers/cpp-objc-en.pdf

Alex Nolasco
  • 18,750
  • 9
  • 86
  • 81
  • 1
    Just checked it out - as expected, it's great for going from C++ to Obj-C ( though it's from 2009, and things have changed a bit ), however, when it mentions key differences between C++ and Obj-C - it assumes you already know the C++ side of the difference, and does little more than jog the memory to explain it, it primarily focuses on the Obj-C side - which you already know - this sadly, limits its usefulness. In short, C++ to Obj-C explanations are not symmetric with Obj-C to C++ explanations. – OverToasty May 13 '13 at 12:46
4

I don't know of a book for learning C++ for the Objective-C programmer. The fact that the Objective-C foundation libraries offer a lot out of the box (not to mention all the other frameworks which are part of the iOS and Mac SDKs, which is the main use-area for Objective-C) which is not covered by the C++ standard libraries might be a reason. The new C++11 standard and the boost C++ libraries go some way to bridging the gap.

There are quite a few articles which describe the main difference including this one.

The understanding of OOP you have aquired in Objective C as well as it's C subset (in your question you say "Obj-C is a subset of C", it's the opposite), will give you a big head start in learning C++, but it seems you have no alternative than to use C++ books and learn directly from them.

EDIT:

Adding the link to the SO post on good C++ books, suggested by @Bart in the comments.

Community
  • 1
  • 1
jbat100
  • 16,757
  • 4
  • 45
  • 70
  • 1
    Sorry, superset then. As a non-native english speaker this is not the first time I confuse superset with subset (I'm thinking of this as subclasses I guess). As I guessed, and judging from my googling there is no book on obj-c -> C++. And probably never will be. Thanks for the information, I will simply start with looking at the obvious differences and then go on with a intermediate book on C++. – sebrock Nov 05 '11 at 16:56