私の主なプログラムは、乱数を生成して 2 次元配列でオブジェクトの動きを作成し、それを追跡することです。
私の関数の 1 つは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 ++が初めてです。