State machine, problems with #include - c++

Hey Im trying to implement state machine for my game and I wanted to test some things out.
So right now my machine has 2 states Pause and Menu each one of them prints one texture and if I press mouse it should change to other state. That should be simple and I think I implemented it right, but I am having 40 bugs and I think its connetcted to include's. Here is how my code looks:
Game.h
#pragma once
#include <SFML/Graphics.hpp>
#include "GameState.h"
#include "Menu.h"
#include "Pause.h"
class Game
{
public:
sf::RenderWindow* window;
sf::Event evnt;
GameState *state; // current state
sf::Texture text1;
sf::Texture text2;
sf::Sprite sText1;
sf::Sprite sText2;
void start(); // Main loop
void print1(); // Prints one graphic
void print2(); // Prints second one
void update();// Prints based on current state
void handleInput(); // check for input
Game();
};
Game.cpp
void Game::start()
{
while (window->isOpen())
{
handleInput();
update();
window->clear();
window->display();
}
}
Game::Game()
{
window= new sf::RenderWindow(sf::VideoMode(1900, 1080), "SFML works!");
text1.loadFromFile("Test.png");
sText1.setTexture(text1);
text2.loadFromFile("background.png");
sText2.setTexture(text1);
state = new Menu();
}
void Game::print1()
{
window->draw(sText1);
}
void Game::update()
{
state->Update(*this);
}
void Game::print2()
{
window->draw(sText2);
}
void Game::handleInput()
{
while (window->pollEvent(evnt))
{
GameState* tmp = state->handleInput(evnt);
if (tmp != NULL)
{
delete state;
state = tmp;
}
}
}
GameState.h
#pragma once
#include "Game.h"
class GameState
{
protected:
public:
virtual void Update(Game &gra )=0;
virtual GameState* handleInput(sf::Event evnt)=0;
};
Pause.h
#pragma once
#include "GameState.h"
#include "Menu.h"
class Pause:public GameState
{
public:
void Update(Game& gra);
GameState* handleInput(sf::Event evnt);
};
Pause.cpp
#include "Pause.h"
void Pause::Update(Game& gra)
{
gra.print1();
}
GameState* Pause::handleInput(sf::Event evnt)
{
if (evnt.type == sf::Event::MouseButtonPressed)
{
return new Menu();
}
else
{
return NULL;
}
}
Menu class works the same, just returns Pause class
Here are the errors, doubt that they will help
Severity Code Description Project File Line Suppression State
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\GameState.h 11
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 9
Error C2660 'GameState::Update': function does not take 1 arguments sfml C:\Programowanie\Nauka\sfml\sfml\Game.cpp 52
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 9
Error C2504 'GameState': base class undefined sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 6
Error C2143 syntax error: missing ';' before '*' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 10
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 9
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 10
Error C2238 unexpected token(s) preceding ';' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 10
Error C2504 'GameState': base class undefined sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 6
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 9
Error C2143 syntax error: missing ';' before '*' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 10
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 10
Error C2238 unexpected token(s) preceding ';' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 10
Error C2143 syntax error: missing ';' before '*' sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C2238 unexpected token(s) preceding ';' sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C2504 'GameState': base class undefined sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 6
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 9
Error C2143 syntax error: missing ';' before '*' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 10
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 10
Error C2238 unexpected token(s) preceding ';' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 10
Error C2143 syntax error: missing ';' before '*' sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C2440 'return': cannot convert from 'Pause *' to 'GameState *' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.cpp 15
Error C2238 unexpected token(s) preceding ';' sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C2504 'GameState': base class undefined sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 6
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 9
Error C2143 syntax error: missing ';' before '*' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 10
Error C2238 unexpected token(s) preceding ';' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 10
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 10
Error C2143 syntax error: missing ';' before '*' sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C2238 unexpected token(s) preceding ';' sfml C:\Programowanie\Nauka\sfml\sfml\Game.h 11
Error C2440 'return': cannot convert from 'Menu *' to 'GameState *' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.cpp 14
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\GameState.h 11
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Pause.h 9
Error C2061 syntax error: identifier 'Game' sfml C:\Programowanie\Nauka\sfml\sfml\Menu.h 9

You have a circular dependency where Game.h includes Gamestate.h and vice versa. In the former you can replace your full include
#pragma once
#include <SFML/Graphics.hpp>
#include "GameState.h" // full include
#include "Menu.h"
#include "Pause.h"
class Game
{
...
with a forward declaration instead
#pragma once
#include <SFML/Graphics.hpp>
#include "Menu.h"
#include "Pause.h"
class GameState; // forward declaration
class Game
{
...
Then you can #include "GameState.h" within your Game.cpp file instead

Related

Why is this code not compiling

I am trying to write a makeshift renderer for the tutorials on
this site. I have two classes SceneObject and RenderComponent. A SceneObject should contain a RenderComponent which should then draw the SceneObject. This is the code:
SceneObject.h
#ifndef _SCENE_OBJECT_H
#define _SCENE_OBJECT_H
#include <GLM/glm.hpp>
#include <GLM/gtc/matrix_transform.hpp>
#include <GLM/gtc/type_ptr.hpp>
#include <vector>
#include <iostream>
#include "..\headers\shader.h"
#include "..\headers\rendercomponent.h"
class SceneObject {
private:
glm::vec3 position;
float *vertices;
RenderComponent* renderComponent;
std::vector<Shader> shaders;
public:
SceneObject(glm::vec3, GLfloat*);
~SceneObject();
bool init();
RenderComponent& getRenderComponent() const;
};
#endif
SceneObject.cpp
#include "..\headers\sceneobject.h"
SceneObject::SceneObject(glm::vec3 pos, GLfloat* objectVertices) {
this->position = pos;
this->vertices = objectVertices;
renderComponent = new RenderComponent(*this);
}
SceneObject::~SceneObject() {}
RenderComponent& SceneObject::getRenderComponent() const {
return *renderComponent;
}
bool SceneObject::init() {
if (!renderComponent->initialize()) {
return false;
}
}
RenderComponent.h
#ifndef _RENDER_COMPONENT_H
#define _RENDER_COMPONENT_H
#include <GLM/glm.hpp>
#include <GLM/gtc/matrix_transform.hpp>
#include <GLM/gtc/type_ptr.hpp>
#include <iostream>
#include "../headers/sceneobject.h"
class RenderComponent {
SceneObject &sceneObject;
public:
RenderComponent(SceneObject&);
RenderComponent(const RenderComponent&);
bool initialize();
void draw();
SceneObject& getSceneObject() const;
};
#endif
RenderComponent.cpp
#include "..\headers\rendercomponent.h"
RenderComponent::RenderComponent(SceneObject& obj)
:sceneObject(obj){}
RenderComponent::RenderComponent(const RenderComponent& ref)
: sceneObject(ref.getSceneObject()){}
bool RenderComponent::initialize() {}
void RenderComponent::draw() {}
SceneObject& RenderComponent::getSceneObject() const {
return sceneObject;
}
The following errors are produced.
Error C2143 syntax error: missing ';' before '&'
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2238 unexpected token(s) preceding ';' syntax error: identifier 'SceneObject'
Error C2143 syntax error: missing ';' before '&'
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2238 unexpected token(s) preceding ';'
Error C2664 'RenderComponent::RenderComponent(const RenderComponent &)': cannot convert argument 1 from 'SceneObject' to 'const RenderComponent &'
Error C2143 syntax error: missing ';' before '&'
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2238 unexpected token(s) preceding ';'
Error C2061 syntax error: identifier 'SceneObject'
Error C2143 syntax error: missing ';' before '&'
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2238 unexpected token(s) preceding ';'
Error C2143 syntax error: missing ';' before '*'
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2238 unexpected token(s) preceding ';'
Error C2143 syntax error: missing ';' before '&'
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2238 unexpected token(s) preceding ';'
From what i understand, the compiler is saying that SceneObject is not a type. I think this where the problem is. Any help is appreciated.
You have sceneobject.h including rendercomponent.h and rendercomponent.h including sceneobject.h. With the include guards one of them doesn't know about the classes defined in the other header.
Remove the include from one or both headers and just forward declare the class(es) instead.

C++ error runing "hello world", vs2010

#include <iostream>
using namespace std;
int main()
{
cout<<"hello world!"<<endl;
return 0;
}
I am trying to run this simplest code in vs2010, but I received more than 100 errors when I was compiling it.
f:\vs2010\vc\include\fstream(14): error C2143: syntax error : missing ';' before '*'
f:\vs2010\vc\include\fstream(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\vs2010\vc\include\fstream(16): error C2653: 'ios_base' : is not a class or namespace name
f:\vs2010\vc\include\fstream(16): error C2061: syntax error : identifier 'openmode'
f:\vs2010\vc\include\fstream(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Errors like these. What should I do?
try to include this lab in your code
#include "stdafx.h"

Getting string compile errors in visual studio using the boost string lib

i am trying to make a program that reads from an ini file but in Visual Studio I keep getting compile errors about string identifiers and semicolons in the wrong place. I am not very good at C++ so it's most likely something really simple, but any way here is the code and error list.
INI.h
#ifndef INI_H
#define INI_H
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
string INIreader(const string&, const string&);
#endif
INI_readnwrite.cpp
#include "INI.h"
using boost::property_tree::ptree;
string INIreader(const string& section, const string& name)
{
ptree pt;
read_ini("GameSettings.ini", pt);
string value = pt.get<string>("section.name");
return value;
}
mainCode.cpp
#include "INI.h"
using namespace std;
int main()
{
string sec = "gameSettings";
string val = "resXY";
cout << INIreader(sec, val);
}
And here is the error list
error// file// line//
error C2872: 'string' : ambiguous symbol maincode.cpp 18
error C2146: syntax error : missing ';' before identifier 'sec' maincode.cpp 18
error C2065: 'sec' : undeclared identifier maincode.cpp 18
error C2872: 'string' : ambiguous symbol maincode.cpp 19
error C2146: syntax error : missing ';' before identifier 'val' maincode.cpp 19
error C2065: 'val' : undeclared identifier maincode.cpp 19
error C2065: 'val' : undeclared identifier maincode.cpp 20
error C2065: 'sec' : undeclared identifier maincode.cpp 20
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini_readnwrite.cpp 6
error C2872: 'string' : ambiguous symbol ini_readnwrite.cpp 6
error C2146: syntax error : missing ';' before identifier 'INIreader' ini_readnwrite.cpp 6
error C2143: syntax error : missing ',' before '&' ini_readnwrite.cpp 6
error C2086: 'int string' : redefinition ini_readnwrite.cpp 6
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini_readnwrite.cpp 7
error C2974: 'boost::property_tree::basic_ptree<std::string,std::string,std::less<Key>>::get' : invalid template argument for 'Type', type expected ini_readnwrite.cpp 10
error C2974: 'boost::property_tree::basic_ptree<std::string,std::string,std::less<Key>>::get' : invalid template argument for 'Ch', type expected ini_readnwrite.cpp 10
error C2146: syntax error : missing ';' before identifier 'value' ini_readnwrite.cpp 10
error C2065: 'value' : undeclared identifier ini_readnwrite.cpp 10
error C2065: 'value' : undeclared identifier ini_readnwrite.cpp 11
IntelliSense: identifier "string" is undefined INI.h 9
IntelliSense: identifier "string" is undefined INI.h 9
IntelliSense: identifier "string" is undefined INI.h 9
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini.h 9
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini.h 9
error C2146: syntax error : missing ';' before identifier 'INIreader' ini.h 9
error C2146: syntax error : missing ';' before identifier 'INIreader' ini.h 9
error C2143: syntax error : missing ',' before '&' ini.h 9
error C2143: syntax error : missing ',' before '&' ini.h 9
Thanks.
You need to use the fully qualified name when you attempt to use std::string in your header file:
std::string INIreader(const std::string&, const std::string&);
And do the same thing in INI_readnwrite.cpp, or add a "using" directive like you did in the other .cpp file:
using boost::property_tree::ptree;
using namespace std;

Function prototypes and enum

I've declared a global enum type in my program and want various functions within my program to return instances of the enum type. Here is my declaration:
#ifndef GLOBAL_H_
#define GLOBAL_H_
#include <SDL.h>
#include "LTexture.h"
#include "LButton.h"
#include "Initializationetc.h"
enum LButtonSprite
{
BUTTON_SPRITE_MOUSE_OUT = 0,
BUTTON_SPRITE_MOUSE_OVER_MOTION = 1,
BUTTON_SPRITE_MOUSE_DOWN = 2,
BUTTON_SPRITE_TOTAL = 2
};
...
However, when I go try and build a function that returns "LButtonSprite" the following happens:
#ifndef LBUTTON_H
#define LBUTTON_H
#include <SDL.h>
#include "Global.h"
class LButton
{
public:
//Initializes internal variables
LButton();
//Sets top left position
void setPosition(int x, int y);
//Handles mouse event
void handleEvent(SDL_Event* e);
//Shows button sprite
void render();
LButtonSprite getCurrSprite();//here
private:
//Button Position
SDL_Point mPosition;
//Button Sprite
LButtonSprite mCurrentSprite; //and here.
};
#endif
It seems as if the Visual Studio is mistaking the function prototype LButtonSprite getCurrSprite(); for a declaration of a variable called getCurrSprite() of type LButtonSprite. The colour coding provided by VS (as seen above) seems to confirm this suspicion. Return types are blue, but LButtonSprite is light blue which is the colour reserved for variables.
The problem isn't just cosmetic unfortunately. I'm getting a bunch ofC4430: missing type specifier - int assumed. Note: C++ does not support default-int. I've added comments to the code at the lines where the error is occurring. The complete error log is included at the end of the post.
How can I correct this mistake?
Error log:
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 14 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\global.h 34 1 SDL2_tutorials
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 20 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 4 error C2146: syntax error : missing ';' before identifier 'mCurrentSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 10 error C2146: syntax error : missing ';' before identifier 'mCurrentSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 19 error C2146: syntax error : missing ';' before identifier 'mCurrentSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 1 error C2146: syntax error : missing ';' before identifier 'getCurrSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 7 error C2146: syntax error : missing ';' before identifier 'getCurrSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 16 error C2146: syntax error : missing ';' before identifier 'getCurrSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Return types are blue
No – keywords are blue. Why else would enum, class, public and private be blue? Return types have no special syntax highlighting. The problem in your code is completely unrelated:
#ifndef GLOBAL_H_
#define GLOBAL_H_
#include <SDL.h>
#include "LTexture.h"
#include "LButton.h"
The last line includes (and thus declares) the LButton class, before you define your enum. Remove that line from the file, or define the enum before.
I'm assuming you use VS2012. In VS2012, all user defined types(return values are no exception) are colored light blue. Dark blue are reserved words.
The reason why your function's return type is light blue is because the return type is a user defined type.
From your code I see you have #include "LButton.h" probably containing the definition of class LButton before declaration of the enum LButtonSprite, therefore the IDE and the compiler does not see the LButtonSprite declared in the LButton, hence the wrong coloring.
You should include it the other way around, LButtonSprite.h into LButton.h

Error declaring vector in header file

I keep receiving a long string of errors when I try to declare a vector in the header. I've looked around for awhile, but can't find a solution.
Here are the errors:
1>Compiling... 1>game.cpp 1>c:\users\legacyblade\documents\visual
studio 2008\projects\fourswords\fourswords\input.h(38) : error C2143:
syntax error : missing ';' before '<'
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2071:
'input::vector' : illegal storage class
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C4430: missing
type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2238:
unexpected token(s) preceding ';' 1>main.cpp
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2143: syntax
error : missing ';' before '<' 1>c:\users\legacyblade\documents\visual
studio 2008\projects\fourswords\fourswords\input.h(38) : error C2071:
'input::vector' : illegal storage class
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C4430: missing
type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2238:
unexpected token(s) preceding ';' 1>input.cpp
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2143: syntax
error : missing ';' before '<' 1>c:\users\legacyblade\documents\visual
studio 2008\projects\fourswords\fourswords\input.h(38) : error C2071:
'input::vector' : illegal storage class
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C4430: missing
type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\legacyblade\documents\visual studio
2008\projects\fourswords\fourswords\input.h(38) : error C2238:
unexpected token(s) preceding ';'
Here is the source code:
#include <vector>
#include <SFML/Graphics.hpp>
#ifndef _input_h
#define _input_h
class input
{
public:
input();
void update();
//----input keys----//
// Directions
bool upPress;
bool downPress;
bool leftPress;
bool rightPress;
// Actions
bool aPress;
bool bPress;
bool jumpPress;
bool shieldPress;
// Menu
bool startPress;
bool screenshotPress;
bool fullscreenPress;
//------------------//
private:
extern vector<sf::Keyboard::Key> keyBindings;
};
#endif
It gives me the same error with and without extern, and even if I change the type of thing inside the vector (even int).
Thank you so much for reading. It would be great if anyone could help. I need vectors to do what I'm wanting to do. Don't know why it's giving me such trouble. Any other type of variable in the same spot DOES NOT cause the error. Only vectors.
Just to add to what's been said, you need the namespace in the declaration because we usually don't want to bloat up header files with "using namespace std". So if you've seen vectors used elsewhere without std:: in front of it, the namespace was probably declared elsewhere.
You need to use the namespace for vector. Prefix vector with std::.
Also, extern on a class member semantically doesn't make any sense. Remove it.
std::vector<sf::Keyboard::Key> keyBindings;
extern vector<sf::Keyboard::Key> keyBindings;
should be
std::vector<sf::Keyboard::Key> keyBindings;