Call a C++ constructor from an Objective C class
Posted
by
syvex
on Stack Overflow
See other posts from Stack Overflow
or by syvex
Published on 2012-09-17T21:27:14Z
Indexed on
2012/09/17
21:38 UTC
Read the original article
Hit count: 202
c++
|objective-c
How can I call a C++ constructor from inside an Objective C class?
class CppClass {
public:
CppClass(int arg1, const std::string& arg2): _arg1(arg1), _arg2(arg2) { }
// ...
private:
int _arg1; std::string _arg2;
};
@interface ObjC: NSObject {
CppClass _cppClass;
}
@end
@implementation ObjC
- (id)init
{
self = [super init];
if ( self )
{
// what is the syntax to call CppClass::CppClass(5, "hello") on _cppClass?
}
return self;
}
@end
© Stack Overflow or respective owner