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):

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


<pre>#pragma once

#ifndef STATE_H
#define STATE_H

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

class Player;
class GrphSettings;
class State;

class StData {
	StData() {};

	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

	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;
	std::map<std::string,sf::Texture> texture;//namespace "std" has no member "string"
	virtual void InitKeybinds() = 0;
	State(StData* Stdata);
	const bool getKeytime();
	const bool& getquit()const;
	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.
Updated 10-Nov-19 21:54pm

1 solution

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

But you may also need:
#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