我不明白为什么我不能定义这个结构: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