I have some very simple source code to expose a simple Foo
class.
main.cpp:
#include <iostream>
#include <lua.hpp>
#include <LuaBridge.h>
class Foo
{
private:
int number = 0;
public:
void setNumber(const int& newNumber) {number = newNumber;}
int getNumber() {return number;}
};
int main()
{
//Expose the API:
lua_State* L = luaL_newstate();
luaL_openlibs(L);
luabridge::getGlobalNamespace(L)
.beginClass<Foo>("Foo")
.addConstructor<void(*)(void)>()
.addProperty("number", &Foo::getNumber, &Foo::setNumber)
.endClass();
}
Unfortunately, I get this error:
24 error: no matching function for call to ‘luabridge::Namespace::Class<Foo>::addProperty(const char [7], int (Foo::*)(), void (Foo::*)(const int&))’
I don't know what the problem is, but I have to use addProperty
otherwise the code doesn't look correct