i keep getting this error in my main.cpp

main.cpp:17: undefined reference to `Game::Game()'

this is the code i have pertaining to the error

#include "Game.h"
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cctype>
#include<fstream>
#include<string>

int main()
{
    ifstream din;

    Game output;
    output.fillGame(din);





    return 0;
}

i doubt it but just in case here is the game.cpp file

#include<iostream>
#include "Game.h"
#include<fstream>
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();
    }
    return true;
}

and .h file. there is other stuff but i didn't include it because it doesn't go with this question

class Game
{
public:
  

    bool fillGame(ifstream & din);
   

};

Recommended Answers

All 4 Replies

Line 13

Game.fillGame(//file)

Line 13

Game.fillGame(//file)

you mean like

output.fillGame("fileName.txt");

you mean like

output.fillGame("fileName.txt");

because i get a different error unless i need an ifstream din in there, which ive tried a few different things with

and the file isthere so thats not the problem

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.