Click here to Skip to main content
15,443,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm recently learning to make a 2d game in SFML using a tutorial series on youtube by Suraj Sharma(currently at video 57):

https://www.youtube.com/watch?v=kwd_AVCkvXE&list=PL6xSOsbVA1ebkU66okpi-KViAO8_9DJKg&index=57

After 10:14 i realized the 'std::map' variables in my 'State' class have the following error:

State.h:

C++
<pre>#pragma once

#ifndef STATE_H
#define STATE_H

#include "Player.h"
#include "GrphSettings.h"

class Player;
class GrphSettings;
class State;

class StData {
public:
	StData() {};

	//Vars
	float GridSize;
	sf::RenderWindow* Window;
	GrphSettings* GSettings;
	std::map<std::string, int>* SupportedKeys;//namespace "std" has no member "string"
	std::stack<State*>* states;
};

class State
{
private:

protected:
	StData* Stdata;
	std::stack<State*>* states;
	sf::RenderWindow* window;
	std::map<std::string, int>* SupportedKeys ;//namespace "std" has no member "string"
	std::map<std::string, int> Keybinds;//namespace "std" has no member "string"
	bool quit;
	bool pause;
	float keyTime; 
	float keyTimeMax;
	float GridSize;

	sf::Vector2i MousePosScr;
	sf::Vector2i MousePosWind;
	sf::Vector2f MousePosView;
	//Resources
	std::map<std::string,sf::Texture> texture;//namespace "std" has no member "string"
	//Funcs
	virtual void InitKeybinds() = 0;
public:
	State(StData* Stdata);
	virtual~State();
	//Access
	const bool getKeytime();
	const bool& getquit()const;
	//Funcs
	void Endstate();
	void PauseSt();
	void UnPauseSt();

	virtual void UpdateInput(const float& dt) = 0;
	virtual void UpdateMousePos();
	virtual void UpdateKeyTime(const float& dt);
	virtual void Update(const float& dt) = 0;
	virtual void Render(sf::RenderTarget* target = nullptr) = 0;
};
#endif // !1


Can anyone help me ?

What I have tried:

I've tried '#include<string>' into the file and it doesn't work.The project works fine before i have no idea what's wrong.
Posted
Updated 10-Nov-19 21:54pm

1 solution

The include for the map class is:
C++
#include <map>

But you may also need:
C++
#include <string>
#include <stack>
if they are not already included in Player.h or GrphSettings.h.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900