tilt
June 19th, 2006, 02:17 PM
New to C++ and Programming in General. Have a quick question about my code.
//Legal Move Generator
void legal_move(vector<int> &move, position board[], int size);
//Generate Moves
void legal_move(vector<int> &move, position board[], int size){
int counter = 0;
for(counter; counter <= size; counter++){
if(board[counter].occupied == 0){
//Assign the value of counter to the vector move, and so on
}
}
}
I would just use an array in the function, but obviously the legal moves will grow and shrink, so I thought a vector would be a better fit. The question is in the comment under the if condition--
Thanks for any help.
//Legal Move Generator
void legal_move(vector<int> &move, position board[], int size);
//Generate Moves
void legal_move(vector<int> &move, position board[], int size){
int counter = 0;
for(counter; counter <= size; counter++){
if(board[counter].occupied == 0){
//Assign the value of counter to the vector move, and so on
}
}
}
I would just use an array in the function, but obviously the legal moves will grow and shrink, so I thought a vector would be a better fit. The question is in the comment under the if condition--
Thanks for any help.