Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <emscripten/bind.h>
- #include <iostream>
- using namespace emscripten;
- class BaseClass
- {
- public:
- BaseClass(){}
- void Hello()
- {
- }
- void Goodbye()
- {
- std::cout << "Goodbye" << std::endl;
- }
- };
- class SubClass : public BaseClass
- {
- public:
- void Hello()
- {
- std::cout << "Hello" << std::endl;
- }
- int Add(int a, int b)
- {
- return a + b;
- }
- };
- EMSCRIPTEN_BINDINGS(Module)
- {
- class_<BaseClass>("BaseClass") // Register base class and all its attributes
- .constructor<>()
- .function("Hello", &BaseClass::Hello)
- .function("Goodbye", &BaseClass::Goodbye);
- //Notice the extra parameter passed to 'class_' template
- // |
- // V
- class_<SubClass, base<BaseClass>>("SubClass") // SubClass will also have all the attributes of baseclass
- .constructor<>()
- .function("Hello", &SubClass::Hello)
- .function("Add", &SubClass::Add);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement