如何在C中使用这些方法?我在某处读到它们可以"用结构指针作为第一个参数的函数替换",但我不知道如何做到这一点,如果这是正确的事情.
struct SCustomKeys
{
struct SCustomKey Save[10];
struct SCustomKey Load[10];
struct SCustomKey Slot[10];
struct SCustomKey PrintScreen;
struct SCustomKey LastItem; // dummy, must be last
//--methods--
struct SCustomKey &key(int i) { return ((SCustomKey*)this)[i]; }
struct SCustomKey const &key(int i) const { return ((SCustomKey*)this)[i]; }
};
Run Code Online (Sandbox Code Playgroud)
以下是如何使用它们的示例:
void ZeroCustomKeys (SCustomKeys *keys)
{
int i = 0;
SetLastCustomKey(&keys->LastItem);
while (!IsLastCustomKey(&keys->key(i))) {
keys->key(i).key = 0;
keys->key(i).modifiers = 0;
i++;
};
}
Run Code Online (Sandbox Code Playgroud)
更多背景信息:http://pastebin.com/m649210e8
谢谢您的帮助.尽管如此,我还没有能够建议替换使用此函数的C++方法.关于如何处理这个的任何想法?
void InitCustomKeys (struct SCustomKeys *keys)
{
UINT i …Run Code Online (Sandbox Code Playgroud)