我的主要程序是生成一个随机数以在二维数组中创建对象的移动并跟踪它。
我的一个函数void current_row(int row){position = row};
跟踪对象的当前行。
因为变量不是全局的。我发现调用当前位置并将其更新到下一个动作的问题。这就是其他函数的样子:
void movement (){
int row;
row = current_row();
/*
* Here is the problem i'm having. This may well be
* a third function which has the same information
* as my first function. But still how do I access
* once without modifying it and access it
* again to update it?
*/
// call another function that creates new row.
// update that info to the row
}
我是 C++ 新手。