Hey everyone!
I am trying to write a program that uses a base class to define an algorithm for solving a simple problem. I use a vector of ints as a 'game board'. My question is how can I create a function get_moves that returns a vector of game boards?
Here is the code I have for the function:
std::vector< <std::vector<int> > takeaway::generateMoves( std::vector<int> currBoard ) {
if( currBoard[0] == 1 || currBoard[0] == 2 ) {
moves.push_back( 1 );
}
else if( currBoard[0] == 3 ) {
moves.push_back( 2 );
}
else if( currBoard[0] == 4 ) {
moves.push_back( 3 );
}
else {
moves.push_back( 1 );
moves.push_back( 2 );
moves.push_back( 3 );
}
std::vector< <std::vector <int > > toReturn( moves );
for( int i = 0; i < moves.size(); i++ ) {
std::cout << "MOVES: " << moves[i] << std::endl;
}
return toReturn;
The errors that I get are:
takeaway.cpp:55: error: template argument 1 is invalid takeaway.cpp:55: error: template argument 2 is invalid
So my question is how can I properly create and return a vector of vectors?