How can I use C++ with Objective-C in XCode

后端 未结 2 1632
南方客
南方客 2020-11-29 09:22

I want to use/reuse C++ object with Objective-C. I have a hello.h that has the class definition, and hello.cpp for class implementation.

class Hello
{ int ge         


        
2条回答
  •  悲哀的现实
    2020-11-29 09:53

    Make sure you compile that file as "Objective-C++".

    The simplest way is to rename it as *.mm.

    If you don't want to rename the *.m file,

    1. Select your file.
    2. Open the File Info dialog (Cmd+I)
    3. In File Type, select "sourcecode.cpp.objcpp"

提交回复
热议问题