純粋仮想クラスの C++ オブジェクトを期待する関数に、純粋仮想 C++ クラスから派生したクラスの Lua オブジェクトを渡したいと思います。これどうやってするの?
私は lua と luabind が初めてなので、ご容赦ください。
C++ の場合:
struct A {
virtual void foo() = 0;
};
void do_something(A* a) {
a->foo();
}
ルアの場合:
class 'MyA' (A)
....
function MyA:foo()
print('hi')
end
再び C++ で:
... // somehow create an instance of MyA class and named myA
// How?
// Maybe the result of a call to "MyA()"?
do_something(myA);