For my assignment I have to do use a previous assignment I did and break it into the following functions:
// get the number of rows from the user, assuring legal and odd,
// then return it to the caller
int GetNRows( void );
There are others I have to write a functions that I need to write for this problem, but I'm really stuck on this first function. When I compile it I get an error that says: "error: expected primary-expression before 'int'" and "error: expected ';' before 'int'" I'm not really sure if I'm approaching this correctly or not. Thank you in advance for your help!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include<iostream>
usingnamespace std;
int GetNRows()
{
int nRows;
cout << "Enter nRows: " << flush;
cin >> nRows;
return nRows;
}
int main()
{
int nRows;
nRows=int GetNRows();
return 0;
}
Also I forgot to mention that inside where you put the parameters it is void so it's int GetNRows(void) also if I return it to caller where should I return it?
And just to mention type function(void) are mostly used for backward compatibility with 'C' language so they maybe necessary if Op want's to maintain that but not required in plain c++.
If it's okay, I sent you(andy1992) a PM of my program and I'm hoping you can look at it when you get the chance. Thanks for the advice! Sorry for the disturbance.