I have a function A(), that returns a pointer to an object. In function B() I try to change a member of that object in the following way:
void B()
{
ObjType o = *getObj();
o.set("abc");
}
Object o is stored in an array, and when I print the value of the member, it seems nothing happened, and the member still has the old value;
The solution is quite simple:
void B()
{
ObjType * o = getObj();
o->set("abc");
}
This does work. But to me, this is quite the same as the first sample. Can anyone explain this?