Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

1. Objective-C Pocket Reference > 1.16. Objective-C++

Objective-C++

gcc is at once a compiler for C, Objective-C, and C++. You can intermix C++ and Objective-C code to some degree. To instruct the compiler that a file contains C++ code as well as Objective-C, use the file extension .mm or .M instead of .m.

Following are some ways in which C++ and Objective-C code can be used together:

  • Objective-C objects can have fields that point to C++ objects, and vice versa.

  • Objective-C code can call methods on C++ objects, and vice versa.

  • Objective-C objects can have C++ objects (as opposed to pointers) as fields, but only if the C++ class has no virtual methods.

However, Objective-C and C++ are not completely compatible. Here are some things you can’t do:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint