reference in class

I have a class called "Graphics", the window(sf::RenderWindow) is created by myself.

I want the Graphics class to change the window so I thought I could have a reference:
1
2
3
4
5
6
7
8
9
10
class Graphics
{
public:
  static void setWindow(sf::RenderWindow& Window)
{
m_Window = Window;
}
private:
  static sf::RenderWindow& m_Window;
};



I get the error that the =operator is denied. But I don't want to copy anything, I just want to use m_Window as a reference to that window. So why is the compiler saying I'm using the "sf::RenderWindow::operator=(const sf::RenderWindow&)"?
A reference cannot be reseated. Setting the "reference" equal to something outside of initialization means that you are operating on the object referred to. If you require changing which object it refers to, consider using a pointer instead.
Thank you, didn't think of that! I'll use pointers instead ;)
Topic archived. No new replies allowed.