Dear Ox users,
When I declare a class db1 and assign it's information to another class db2, ie
db2=db1, changes to db2 also affects db1. Is this normal, and how can I avoid
it?
The following program illutrates:
#include <oxstd.h>
#import <database>
main()
{ decl z1,z2,m1,m2,db1=new Database();
static decl db2;
db1->Create(1,1,1,10,1);
db1->Deterministic(0);
db2=db1;
m1=db1->GetAll();
z1=db2->GetAll();
z2=z1[ranu(1,10)*10][];
db2->RenewBlock(z2,0);
m2=db1->GetAll();
println(m1,"\n\n",m2);
}
I would suppose that the changes to db2 would have no effect on db1, so that m1
and m2 would be similar. But they are not.
Best regards,
Jo Thori Lind
|