0

Newbie question, possibly just confused. Thanks in advance:

Suppose I have an instance of an object (or perhaps a struct), obj1, of class class1. The following is standard pointer assignment:

class1 *p1 = &obj1;

And from now on, I can access the object's members by p1->member.

Question: How do I "go back", i.e., if I write:

class1 obj2 = *p_var;

one could think obj1 and obj2 were the same; but in reality, this last call just create a new object and called the copy constructor (I think).

Is there a way to make obj2 refer to the same instance as obj1, or this goes against the whole concept of "object"? Any references on this would also be useful.

Thank you!!

0 Answers0