# Objective-C and C++? (And Qt!)



## raydot (Mar 28, 2008)

All,

For a personal project I want to create a simple 2D game that I can use to build out some AI classes and the like in C++.

Does anyone know of any resources that describe how to add C++ classes into your XCode projects? Everything out there seems to be written in Objective-C, or doesn't include any discussion of graphics (not game-type graphics, at least).

I don't mind doing the graphics whichever way but I'd like the AI classes to be in C++. Any suggestions on how to bridge the gap? Can Objective-C and C++ even be mixed in a single application? Any thoughts on Qt?

Thanks.


----------



## Mikuro (Mar 29, 2008)

Objective-C and C++ can indeed be mixed, in a hybrid called Objective-C++. The short answer is that you need to rename your Objective-C .m files to .mm to use C++ code in them. See http://www.cocoadev.com/index.pl?ObjectiveCPlusPlus for more info. (And bookmark that site, because it will be your new best friend.)

As for graphics, you'd probably want to use OpenGL, or perhaps find a C/C++ sprite framework based on OpenGL.


----------



## raydot (Mar 29, 2008)

Thanks Mikuro!  This is a huge help.  I knew a solution had to be out there.


----------

