getGlobalNamespace(L)
.beginClass<A>("A")
.addConstructor()
.endClass()
.deriveClass<B1, A>("B1")
.addConstructor()
.endClass()
.deriveClass<B2, A>("B2")
.addConstructor<void(*)(void)>()
.endClass()
How to register two class inherited from the same class using LuaBridge?
Question
I'm trying to register two class that inherit from the same class using LuaBridge, but failed.
How can I register three classes below?
class A { public: int x; }; class B1 : public A { public: int y; }; class B2 : public A { public: int z; };
I can just register A and B1 like this
getGlobalNamespace(L) .beginClass<A>("A") .addConstructor() .endClass() .deriveClass<B1, A>("B1") .addConstructor<void(*)(void)>() .endClass()
And
getGlobalNamespace(L) .beginClass<A>("A") .addConstructor() .endClass() .deriveClass<B1, A>("B1") .addConstructor() .endClass() .deriveClass<B2, A>("B2") .addConstructor<void(*)(void)>() .endClass()
is turn out to register B2 as if it inherits from B1.
Any help is greatly appreciated.
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow