我不明白爲什麼我不能定義這個結構:C++定義結構與模板
//Class.h
template <class T>
struct Callback {
T* Object;
std::function<void()> Function;
};
template <class T>
struct KeyCodeStruct {
typedef std::unordered_map<SDL_Keycode, Callback<T>> KeyCode;
};
template <class T>
struct BindingStruct{
typedef std::unordered_map<int, KeyCodeStruct<T>> Binding;
};
class Class {
public:
template <class T>
void bindInput(SDL_EventType eventType, SDL_Keycode key, Callback<T> f);
private:
template <class T>
BindingStruct<T> inputBindings; //How do I define this? This gives me an error.
}
它給人的錯誤: Member 'inputBindings' declared as a template.
我不知道模板非常好,所以我可能只是錯過我需要的信息。
更新(針對deviantfan)
現在我的CPP類運行到一個函數我有問題。
template <class T>
void InputManager::bindInput(SDL_EventType eventType, SDL_Keycode key, Callback<T> f)
{
inputBindings[eventType][key] = f;
}
它說預期的類或命名空間。
請張貼完整的錯誤消息,並且在哪一行它發生。 – deviantfan 2014-09-21 23:13:34
@TrevorPeyton看起來完全不同的問題。 – juanchopanza 2014-09-21 23:14:06
@juanchopanza我試圖保持源代碼的最低限度。我不認爲這些會受到他的職位的影響。 – TrevorPeyton 2014-09-21 23:16:35