I am following a guide on SFML and have met a pitfall. From what I understand, the writer was using psuedocode since his original code was:
class World : private sf::NonCopyable
{
public:
explicit World(sf::RenderWindow& window);
private:
sf::RenderWindow& mWindow;
};
I believe this is psuedocode because you have to initialize a reference first.
So I consulted my Stroustrup book and found that I can do it like this.
#pragma once
#include <SFML/Graphics/RenderWindow.hpp>
class Renderer : private sf::NonCopyable
{
public:
Renderer();
Renderer(sf::RenderWindow &newWindow) :renderWindow(newWindow) {}
~Renderer();
private:
sf::RenderWindow& renderWindow;
};
But I am missing the syntax for the cpp file, I get errors for these.
Renderer::Renderer() {}
Renderer::~Renderer()
{
}
'Renderer::renderWindow;' references must be initialized
I've searched for a few hours for the answer, but either I am god awful at using keywords or it's just not an easy topic to find. Any help, suggestions or criticisms are greatly appreciated.