I have a global assigned as a pointer to my window like this:
globals.cpp & globals.h has:
#include <SFML/Graphics.hpp>
sf::RenderWindow* window
Then in main.cpp i put:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <map>
#include <string>
using namespace std;
#include "globals.h"
window(VideoMode( (800,600) , "Test") ); //line 22
How ever this appears to be incorrect. As i get this error:
main.cpp(22): error C2228: left of '.VideoMode' must have class/struct/union
What am doing wrong here?
Maybe I’ve totally misunderstood the question, but why do you have the pointer defined in both the header and the source file? Seems to me you should do the following:
In globals.h
In globals.cpp
In main.cpp
And don’t forget to
deletewindow once you’re done with it.Also, I strongly urge you to replace the global pointer with
and initialize it as
Now you don’t need to worry about
deleteing it!