【发布时间】:2015-12-16 22:40:14
【问题描述】:
我在 cpp 中有一个类,例如:
class Foo{
private:
int x;
public:
Foo(){x = 0;}
int incr();
};
int Foo::incr(){
x++;
return x;
}
在任何 .hx 文件中,我想使用像这样在 cpp 中定义的 Foo 类:
var number:Int;
// Some codes to create foo_1 object "Foo foo_1;"
// Some codes to call "number = foo_1.incr();"
trace("x is:" + number);
// Some codes to call "number = foo_1.incr();"
trace("x is:" + number);
预期输出是
x is:1
x is:2
作为说明,我搜索并阅读了一些关于 hxcpp 和 Haxe CFFI 的文档,但这些文档的某些部分过于复杂。我是 Haxe 的初学者,我需要基本和简单的步骤来解决这个问题。谢谢。
【问题讨论】: