You need to write a copy constructor. Your default constructor isn't invoked when an instance is copied, and the compiler-generated copy constructor will copy the parent
pointer from the original instance.
A(A const &other) : parent(this) {}
You may want to write a copy-assignment operator too, to preserve the parent
pointer when one instance is assigned to another.
Also, think about what should happen when copying or assigning from an instance whose parent
has been changed from its default. In that case, should the copy/assignee get the same parent as the original? If so, your copy constructor and assignment operator will have to check whether parent == this
and behave differently depending on the result. It may be simpler to just use nullptr
as the default value — either way you need special-case handling for instances without parents, but a null pointer at least makes it obvious that no "real" parent has been assigned yet.