I know that if I do something like this:
class Obj
{
public:
int* nine;
};
Obj Obj1; //Awesome name
int eight = 8;
Obj1.nine = &eight;
Obj Obj2 = Obj1; //Another Awesome name
then Obj1
's and Obj2
's nine
s will point to the same 8
, but will they share the same pointer? I.e.:
int Necronine = 9;
Obj1.nine = &Necronine;
Obj2.nine == ???
will Obj2
's nine
point to Necronine
, or will it remain pointing at 8
?
It will remain pointing at 8. When this line is executed: Obj Obj2 = Obj1; // every object has his own pointer the
value(copy)
ofobj1.nine
is copied intoobj2.nine
and thats it.