So I'm on the first leg of my project and I am stuck on this detail:
"Your program should be organized into several functions. The only code you may write in main is to declare variables and call the functions properly to achieve the overall functionality of the program. The program should have the following functions:
The getBoardSize function should have two reference type parameters for the board dimensions and will have a void return type. This function will prompt the user to enter the board size and read the number of rows and columns into the reference parameters."
This is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <cstdlib>
usingnamespace std;
void getBoardSize(int& rows, int& columns)
{
cout << "Enter the number of rows and columns in your grid, "
<< " separated by a space." << endl;
cin >> rows >> columns;
cout << rows << columns << endl;
}
int main()
{
getBoardSize();
system("pause");
}
When I call getBoardSize(), shouldn't my code execute what happens in that function in the main function? Perhaps I am not setting this up right. Any tips?
you need to give two int variables to your getBoardSize function because your function header specifies that there will be two ints passed to it. So the compiler is expecting to see two ints being passed to the function and when it doesn't see them the compiler assumes there is a problem and complains.