c++ oc
来源:互联网 发布:如何查淘宝搜索热度 编辑:程序博客网 时间:2024/06/07 20:52
object-c---C++相互调用
1.parent.h 虚类
/* 对外边 C++ 文件的接口只用 parent.h 文件 调用 parent *p = createChildren(); */#include "cocos2d.h"class parent{public: bool isFull; int typeTag;public: parent(){}; ~parent(){}; virtual void callChildren() = 0;};extern parent* createChildren();
2.children.h
#import <MediaPlayer/MediaPlayer.h>//引进用到的 object-c 头文件#include "parent.h"#include "cocos2d.h"USING_NS_CC;class children : public parent{private: MPMoviePlayerController *player;//可以定义 object-c 变量 public: children(); ~children(); void callChildren();};
3.children.mm
#include "children.h"#import "EAGLView.h"using namespace std;//Object-c 类@interface ObjectC : NSObject{}- (void) callObjectC:(int) cint;@end@implementation ObjectC- (void) callObjectC:(int) cint{ NSLog(@"call object %d", cint);}@endstatic ObjectC *s_oc = nil;static parent *s_parent;//C++类的实现parent* createChildren(){ s_parent = new children(); return s_parent;}void children::callChildren(){ /*可以创建 object-c 对象*/ s_oc = [ObjectC alloc]; [s_oc callObjectC: 1];}children::children(){}children::~children()//释放object-c 和 c++ 对象{ [s_oc release];}
0 0
- C、C++、OC混编
- c,c++,oc混编
- C++/OC 混编
- C++/OC 混编
- 从 c 进入oc
- iOS C++/OC 混编
- oc c 取绝对值
- OC和C混编
- C++/OC 混编
- 【Objective-C】OC基础
- [Objective-c] OC介绍
- C与OC
- c/cpp/oc混编
- C和OC 字符串
- OC调用c/c++
- c 调用 oc
- C调用OC方法
- OC-C混编
- 001_014 Python 改变多行文本字符串的缩进
- 从没静下心来
- code forces 397B On Corruption and Numbers
- Linux的10个经典彩蛋
- WebService基础
- c++ oc
- Android_Service组件详解
- 关于nextLine()和next()的使用,区别
- Gas Station
- openURL的使用方法:
- 在grep和sed中用到的简单正则表达式
- IntelliJ IDEA 快捷键大全
- Android_BroadcastReceiver广播接收者详解及应用
- servlet