I have a class with a pointer member, something like:
class MyClass
{
public:
void setPointer(Pointer* ptr){_pointer = ptr;}
private:
Pointer* _pointer{nullptr};
};
MyClass doesn't own the memory to _pointer. It just has a pointer to invoke methods it requires.
I started to write ~MyClass() and I fortunately I realised it shouldn't delete _pointer because it doesn't own it.
What is the best way to show MyClass doesn't have ownership of that pointer?
EDIT:
Should I use a unique_ptr in the owner class and a shared_ptr in MyClass, or should they both use shared_ptr?