sometimes when a class has attributes that are pointers, it can be confusing whether this object is responsible for deleting the object being pointed to.
I would like to know if it is a common strategy to have class attributes that are references. With references this confusion would not be there.
So I thought I can say: "if an object A is the owner of another object B and is responsible for deleting it, then it will have as an attribute a pointer to it. If an object A uses another object B but is not responisble for creating or deleting it, then it will have a reference to it".
1 2 3 4 5 6 7 8 9
B* b; // A is responsible for creating and destroying b
B& b; // C is merely using b and is not responsible for creating and destroying it
Does anybody know if that is common? Or are there drawbacks that I am not aware of?