修改C ++指针所在的值

时间:2018-03-29 14:22:38

标签: c++ pointers reference

我有一个接收指针的函数,我想修改指针所在的位置值。

// How a 'State' looks like 
State s = std::array<std::array<Player,7>,6>;

// I'm receiving a pointer to the state
void Set(State *s, int col, int row, Player player) 
{
    // Modify the state (s)
    s[row][col] = player; // not working
    *s[row][col] = player; // not working
    s->[row][col] = player; // compile error
}

如何使用指针正确修改值(播放器)?

0 个答案:

没有答案