#include <iostream>
#include <luabind/luabind.hpp>
#include <luabind/function.hpp>
extern "C"
{
#include "lua5.1/lua.h"
#include "lua5.1/lualib.h"
#include "lua5.1/lauxlib.h"
}
using namespace std;
class NumberPrinter
{
public:
NumberPrinter( int number )
: m_number( number )
{
}
void print()
{
cout << m_number << endl;
}
private:
int m_number;
};
int main()
{
lua_State* myLuaState = luaL_newstate();
luaL_openlibs( myLuaState );
luabind::open( myLuaState );
luabind::module( myLuaState )[luabind::class_<NumberPrinter>( "NumberPrinter" )
.def( luabind::constructor<int>() )
.def( "print", &NumberPrinter::print )];
luaL_dofile( myLuaState, "demo3.lua" );
lua_close( myLuaState );
}
Print2000=NumberPrinter(20000)
Print2000:print()
20000