TUTORIAL · STEP 1 OF 7
Functions and classes
crossbind reads your C++ header and binds everything it declares. There is no glue code and no binding file: the header is the interface.
native.h declares a function, greet, and a class, Counter; native.cpp defines them. Press Run: main.js finds both on Module.
A std::string crosses as a JavaScript string and an int as a number. The class arrives as a JavaScript class: new Module.Counter(41) runs the C++ constructor, and its methods are ordinary methods.
In a project you import the same names from the header itself and call initNative() once; the quick start sets that up. Here the page does it for you and hands main.js the module as Module.
Try it
Add int add(int a, int b); to native.h, define it in native.cpp and call Module.add(2, 3) from main.js. A change to the C++ compiles on the playground server; a change to main.js alone runs right away.