I'm assuming your talking about something like this ( i had the below code before i posted) but when i do that i get the errors below the code
1 2 3 4 5 6 7 8 9 10 11
int main()
{
Game output;
output.fillGame(ifstream & );
return 0;
}
1 2 3 4 5
main.cpp:16: error: expected primary-expression before ‘)’ token
In file included from main.cpp:4:
Game.cpp:7: error: declaration of ‘std::ifstream din’ shadows a parameter
Game.cpp:7: error: aggregate ‘std::ifstream din’ has incomplete type and cannot be defined
You need to create stream object and pass it to Game member method and remove local one in fillGame or remove it from arguments since you are creating one in "fillGame" scope:
1 2 3 4 5
bool Game::fillGame(ifstream &din)
{
int round_Of;
ifstream din;//you got this one
Also try this instead for fail on open:
1 2
//if(!din)
if(!din.fail())
And you cannot call function like this:
output.fillGame(ifstream & );
...and fillGame expects that you return bool but you didn't do that anywhere in it!
alright i wold have changed it but i asked and i was told that it has to be bool Game::fillGame(ifstream &din)
but i did take out the second one i had inside fillGame.
so now my problem is this
1 2
main.cpp:18: error: expected primary-expression before ‘&’ token
main.cpp:18: error: ‘din’ was not declared in this scope
this is what i changed main too
1 2 3 4 5 6 7 8 9
/* when i uncommet the below line if only gives the main.cpp:18: error: expected primary-expression before ‘&’ token*/
// ifstream din;
Game output;
output.fillGame(ifstream & din);