Hello there all,
I am very new to CPP, but I have a question I couldn't get it settle searching..
private:
class Game {
private:
sf::RenderWindow window;
public:
Game() {
this->window.create(sf::VideoMode(600, 500), this->name, sf::Style::Close);
this->player(this->window);// instantiated window
}
Player player;
};
class Player {
private:
sf::RenderWindow w;
public:
Player(sf::RenderWindow& window)
: w(window)
{
this->w; // window reference from Game class Available globally in Player Class this->w
}
};
int main() {
Game game;
return 0;
}
I don't want to be passing reference of window on every class method in Player class and I don't want to pass it in main.cpp and pass it as reference from a normal object to both classes because I know works using the list initiator in the constructors.