Im trying to read from a file using classes and objects. i keep getting this error

main.cpp:16: error: no matching function for call to ‘Game::fillGame()’
Game.h:41: note: candidates are: bool Game::fillGame(std::ifstream&)

here is code that goes with the error

//Game.h

 bool fillGame(ifstream & din);
//Game.cpp

#include<iostream>
#include "Game.h"

bool Game::fillGame(ifstream &din)
{
int round_Of;
ifstream din;


    din.open("file.txt");
    if(!din)
        cout << "Error: file could not be found";
    else
    {
        din >> round_Of;
        while(!din.eof())
        {
            cout  << round_Of;
            din >> round_Of;
        }
        cout << endl << endl;
        din.close();
    }

}
//main.cpp

#include "Game.h"


#include<iostream>
#include<cstring>
#include<iomanip>
#include<cctype>
#include<fstream>
#include<string>

int main()
{
    Game output;
    output.fillGame();





    return 0;
}

I would just eliminate that parameter, as you are creating a new ifstream object within the body of the method anyway. You may want to rethink your implementation a bit, because all you are doing is writing to the same int value over and over again, and that int is being destroyed once you leave the method anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.