2011-08-31 36 views

回答

1

我認爲,很明顯應該工作的時候編譯爲目的C++:

#if defined __cplusplus 
namespace Foo { class MyCPPClass; } // forward class declaration 
#else 
/*not sure here*/ /*namespace Foo { typedef struct MyCPPClass MyCPPClass; }*/ // forward struct declaration 
#endif 

@interface MyOCClass : NSObject 
{ 
@private 
    Foo::MyCPPClass* cppObject; 
} 

// methods and properties 

@end 

Qt的項目有一個批次的examples混合使用C++和Objective-C。

+0

還有另一種方法,我發現你也在#ifdef中包裝實例聲明。 –

+0

很酷,你能接受答案嗎? – silverjam