I have a question about the usage of copy constructors. I know that there are many other answered questions and a huge variety of tutorials but I could not completely solve my problem.
I have a class A which implements a copy constructor:
A::A(const A& a) { ....... }
Now in another class B, I have a private attribute:
A myA;
During execution, a method of B gets called with a pointer to an A object, lets call it anAPointer. I now want to copy the element pointed by anAPointer into B::myA. If the element behind the pointer later changes, I don't want these changes to affect the myA attribute.
I used this->myA = A(*anAPointer); yet. Does this have the effect I want it to have?
And do I have to call delete myA in B's destructor?