mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
57d9a05f88
- 🛠 Make sure the tutorials compile across platforms! - ✍ Redo quite a bit of the documentation
33 lines
457 B
C++
33 lines
457 B
C++
#define SOL_ALL_SAFETIES_ON 1
|
|
#include <sol/sol.hpp>
|
|
|
|
struct A {
|
|
int a = 10;
|
|
virtual int call() {
|
|
return 0;
|
|
}
|
|
virtual ~A() {
|
|
}
|
|
};
|
|
struct B : A {
|
|
int b = 11;
|
|
virtual int call() override {
|
|
return 20;
|
|
}
|
|
};
|
|
|
|
int main(int, char*[]) {
|
|
|
|
sol::state lua;
|
|
|
|
lua.new_usertype<B>("A", "call", &A::call);
|
|
|
|
lua.new_usertype<B>("B",
|
|
"call",
|
|
&B::call,
|
|
sol::base_classes,
|
|
sol::bases<A>());
|
|
|
|
return 0;
|
|
}
|