Is it possible to initialise two classes, that require pointers to each other, at the same time?
问题 I am making a snake game. I have two classes, snake and food . When I call snake->move() it needs to check that there are no collisions and for this purpose it needs to know what food 's position is and therefore requires a pointer to food . food has a function that moves it to a new random position, move->setNewPosition() , which needs to know the position of snake so that it doesn't collide with the snake when it moves. For this purpose, it requires a pointer to snake . Therefore, for both