Reputation: 1287
When i try to compile my header file, the compiler tells me " 'map' was not declared in this scope" ( the line below public:
). Why?
#pragma once
#include <SFML/Graphics.hpp>
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>
#include <vector>
#ifndef TILEMAP_H
#define TILEMAP_H
class TileMap{
public:
std::vector<std::vector<sf::Vector2i>> map;
std::ifstream file;
TileMap(std::string name);
sf::Sprite tiles;
sf::Texture tileTexture;
void update();
void draw(sf::RenderWindow* window);
};
#endif
Upvotes: 2
Views: 3299
Reputation: 1958
You should have an space between two ">" otherwise compiler will be confused it with ">>" operator. So do like this:
std::vector<std::vector<sf::Vector2i> > map;
That's why it's always a good idea to typedef STL types if you want to use one inside another. So it's better to do like this:
typedef std::vector<sf::Vector2i> Mytype;
std::vector<Mytype> map;
This way you won't get compilation error because of forgetting to put space in between of ">".
Upvotes: 6