我在我的C++应用程序中嵌入了Lua。嵌入Lua和重载的C++运算符
我有一个类Foo,我正在接触Lua(通过tolua ++)。
符重载一些运营商如下图所示:
class Foo
{
public:
explicit Foo(const int i);
bool operator==(const Foo& foo) const;
bool operator< (const Foo& foo) const;
int operator-(const Foo& foo) const;
private:
int m_ival;
};
我的问题是,在我的Lua脚本,我可以再使用类似如下图所示,在我的Lua脚本表达式:
f1 = Foo:new(42)
f2 = Foo:new(123)
if f1 < f2 then
print(f2 -f1)
end
当你尝试时会发生什么? – 2010-12-23 11:11:35