C++ class in Cocoa
Any ideas why Xcode wont let me define a c++ class in my cocoa project?
I am trying to use a C++ class in my cocoa project but I am getting build errors just crea开发者_JAVA百科ting the c++ header file.
class SomeClass{
public:
int count;
};
Expected '=', ',', ';', 'asm' or 'attribute' before 'SomeClass' in .....
If I remove all code from the header file, ?the cpp file builds without any errors and is included in the list of compiled sources...
Ensure that your Objective-C source files have the .mm
extension so that they are treated as Objective-C++ files (there are other ways of getting Xcode to treat your files as Objective-C++ source even if they don't have the .mm
extension, but it is easier just to use the .mm
extension), and also follow PeterK's advice about appending a semicolon after the class declaration.
I think you need to add a semicolon:
class SomeClass{
public:
int count;
};
精彩评论