Original Post
Hi, I'm new to Lua so bear with me. I followed luabinds manual regarding deriving lua classes from ones defined in c++. But It doesn't work: C++: Lua: The problem is if I put the super in the class constructor the program just exits and if I don't put it there the vtable is not constructed correctly(The constructor of Test is never called). To me it looks exactly like the example given in the manual... Thanks in advance.
class Test
{
public:
Test(){cout << "Test constructor.\n";}
virtual void Over(){};
void DoIt()
{
cout << "DoIt!" << endl;
}
};
class TestWrapper : public Test,public luabind::wrap_base
{
public:
TestWrapper() : Test()
{
}
virtual void Over()
{
call<void>("Over");
}
static void DefaultOver(Test *ptr)
{
ptr->Test::Over();
}
};
luabind::module(L)
[
luabind::class_<Test,TestWrapper>("Test")
.def(luabind::constructor<>())
.def("DoIt",&Test::DoIt)
.def("Over",&Test::Over,&TestWrapper::DefaultOver)
];
class 'MyTest' (Test)
function MyTest:__init() super() end
t=MyTest()
t:DoIt()
t:Over()