4
首先,我使用最新的mingw發行版在windows上使用代碼塊。我使用sfml庫開始遊戲,但不幸的是我遇到了這個問題。我需要爲狀態管理器使用std :: function,但它一直顯示相同的錯誤:'std :: function'尚未聲明。我做了#include<functional>
並使用鏈接器選項-std = C++ 0x,但仍然沒有運氣。唯一不編譯的是這個頭文件:Mingw'std :: function'尚未聲明?
#ifndef STATEMANAGER_HPP_INCLUDED
#define STATEMANAGER_HPP_INCLUDED
#include <vector>
#include "State.hpp"
#include <functional>
#include <SFML/Graphics.hpp>
class StateManager {
public:
StateManager();
~StateManager();
void registerState(int id, std::function< State*() > createFunc);
void setState(int id);
void update();
void draw(sf::RenderTarget &target);
private:
std::vector< std::function< State*() > > mStates;
State *mCurrentState;
};
#endif // STATEMANAGER_HPP_INCLUDED
我不知道問題出在哪裏。任何人都知道這裏錯了什麼?
使用'--std = C++ 11'而不是過時的'C++ 0x' – Jarod42 2014-08-31 16:36:39
wil std :: tr1 :: function工作嗎? –
2014-08-31 16:37:24
@PiotrS。然後它說tr1不是標準的成員 – user3452725 2014-08-31 16:40:43