As long as new issues are growing out of my previous question Overloaded assignment operator causes warning about recursion, I was legitimately urged to post this as new one. I have a reference class member in my class Player and I want to implement the copy constructor and the assignment operator (=) of this class. I have to mention that the purpose is the fine working of the function vector.erase because without that it does not work properly as far as I am concerned. I use a vector: vector allPlayers; The members of the class Player are:
class Player
{
private:
int ID;
int pMoney;
int doubleIndicator;
int squarePosition;
Bank& bank;
string pName;
Square* capturedSquare;
multimap<string, PropertySquare*> squaresColBought;
multimap<string, House*> housesColBuilt;
}
Is it mandatory to avoid the use of reference as class member if I want to implement the assignment operator? What about the map members? How should I finally implement the assignment operator?
Another issue of utmost importance of which I am unaware is what happens to the objects pointed by pointers class members when I erase the iterator of the vector which hold the Player. Any help?