I'm trying to create one window in a static variable and using a static function to return this variable to other classes and put them in reference-variables. But I keep getting:
(error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable' ...\sfml-2.0-rc\include\sfml\window\window.hpp 476)
and:
(error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable' ...\sfml-2.0-rc\include\sfml\graphics\rendertarget.hpp 369)
Window.h
#include <SFML/Graphics.hpp>
class Window
{
public:
Window();
static sf::RenderWindow getWindow();
private:
void loadWindow();
static sf::RenderWindow mWindow;
};
Window.cpp
#include "Window.h"
sf::RenderWindow Window::mWindow;
Window::Window()
{
loadWindow();
}
void Window::loadWindow()
{
mWindow.create(sf::VideoMode(1280, 768), "Robot split");
}
sf::RenderWindow Window::getWindow()
{
return mWindow;
}
In the class where I'm trying to call the function Window::getWindow() looks like this:
Game.h
sf::RenderWindow& mWindow;
Game.cpp
#include "Window.h"
Game::Game(): mWindow(Window::getWindow())
In my mind this should give the adress from the static variable in Window.cpp to a reference-variable in Game.cpp, and thus Game.cpp should be able to access the window I create in Window.cpp. Or am I totally off course?