Let's say I have two classes:
class B
{
public:
int foo;
};
class A
{
public:
B b;
};
In c++, if I say:
A a;
a.b.foo = 1;
B b = a.b;
b.foo = 2;
then a.b.foo will have value 1, and b.foo will have value 2.
But in lua, if I say:
a = A()
a.b.foo = 1
b = a.b
b.foo = 2
Then both a.b.foo and b.foo will have value 2, because lua handles userdata by reference. Is there any way to override this behavior, so it behaves like c++?