-3

C++ 用の客観的 C ラッパーの作成について、非常に疑問があります。ビルドしようとすると、コードにエラーが発生します。何が間違っているのかわかりません。ヘルプやガイドをいただければ幸いです。以下は私が書いたサンプルコードです:

///Print.h///
int test1();

///Print.cpp///

int test1()
{
    printf ("hello man\n");
}

///cppWrapper.h///

struct Print;

typedef struct Print Print;

@interface cppWrapper : NSObject
{
    Print *print;
}
@property (nonatomic, assign) Print *print;

-(id)init;

-(int)runTest;

///cppWrapper.mm///

#import "cppWrapper.h"

@implementation cppWrapper

@synthesize print = _print;

- (id)init
{
    self = [super init];

    if (self)
    {
        _print = new Print(); //error occurred here. 
    }

    return self;
}

-(int)runTest
{
    self.print->test1();
}
4

1 に答える 1