I assumed you want to move the instance of an entity from sendingSquare to receivingSquare, and adjust the currentSq of the moved entity so that it rever to receivingSquare.
if that is the case, the code below will do that:
#include <iostream>
using namespace std;
class Square;
class Entity
{
public:
Square *currentSq;
Entity(): currentSq(NULL){}//set currentSq to NULL using constructor initialization list
};
class Square
{
public:
Entity *occupant;
Square(): occupant(NULL){}//set occupant to NULL using constructor initialization list
};
//MOVE_TO with single '*'
void MOVE_TO(Square *sendingSquare, Square *receivingSquare)
{
Entity *movingOccupant = sendingSquare->occupant;
receivingSquare->occupant = movingOccupant;
movingOccupant->currentSq = receivingSquare;
sendingSquare->occupant = NULL;
}
int main(int argc, char** argv) {
//create instances
Square *sendingSquare = new Square(), *receivingSquare = new Square();
Entity *entity = new Entity();
//set up instances accordingly
sendingSquare->occupant = entity;
entity->currentSq = sendingSquare;
//print instances address before MOVE_TO invoked
//we know that receivingSquare.occupant is NULL, printing receivingSquare.occpuant.currentSq is commented
cout << "sendingSquare: "<< sendingSquare
<< ", sendingSquare.occupant: " << sendingSquare->occupant
<< ", sendingSquare.occupant.currentSq: " << sendingSquare->occupant->currentSq
<< ", receivingSquare: " <<receivingSquare
<< ", receivingSquare.occupant: " << receivingSquare->occupant
//<< ", sendingSquare.occupant.currentSq: " << receivingSquare.occupant->currentSq
<< endl;
MOVE_TO(sendingSquare,receivingSquare);
//print instances address afer MOVE_TO invoked
//we know that sendingSquare.occupant is NULL, printing sendingSquare.occpuant.currentSq is commented
cout << "sendingSquare: "<< sendingSquare
<< ", sendingSquare.occupant: " << sendingSquare->occupant
//<< ", sendingSquare.occupant.currentSq: " << sendingSquare.occupant->currentSq
<< ", receivingSquare: " << receivingSquare
<< ", receivingSquare.occupant: " << receivingSquare->occupant
<< ", receivingSquare.occupant.currentSq: " << receivingSquare->occupant->currentSq
<< endl;
//commenting instance deletion. The program is ended anyway
//delete entity,sendingSquare,receivingSquare;
return 0;
}