I don’t even know where to go with this. Google wasn’t very helpful. As with my previous question. I’m using TextMate’s Command+R to compile the project.
game.h:16:error: declaration of ‘Player* HalfSet::Player() const’
players.h:11:error: changes meaning of ‘Player’ from ‘class Player’
game.h:21:error: ‘Player’ is not a type
player.h file (partial)
#ifndef PLAYERS_H #define PLAYERS_H using namespace std; #include <string> #include <vector> #include <istream> #include <iomanip> #include "generics.h" class Player{ //Line 11 public: //getters long Id() const; string FirstName() const; string LastName() const; string Country() const; //setters void setId(long id); void setFirstName(string s); void setLastName(string s); void setCountry(string s); //serializing functions void display(ostream &out); void read(istream &in); void write(ostream &out); //Initalizers Player(); Player(istream &in); Player(string firstName, string lastName); Player(string firstName, string lastName, string country); Player(long id, string firstName, string lastName, string country); ~Player(); private: long _id; string _firstName; string _lastName; string _country; };
game.h file (partial)
#ifndef GAME_H #define GAME_H #include "generics.h" #include "players.h" #include <string> #include <vector> #include <istream> #include <iomanip> using namespace std; class HalfSet{ public: //getters Player* Player() const; //Line 16 int GamesWon() const; int TotalPoints() const; int Errors() const; //setters void setPlayer(Player* p); void setGamesWon(int games); void setTotalPoints(int points); void setErrors(int errors); //Serialization void display(ostream &out) const; void read(istream &in) const; void write(ostream &out) const; //Initalizers HalfSet(); ~HalfSet(); private: Player* _player; int _gamesWon; int _points; int _errors; };
What is going on here?
In C++ you cannot name a function the same name as a class/struct/typedef. You have a class named ‘Player’ and so the HalfSet class has a function named ‘Player’ (‘Player *Player()’). You need to rename one of these (probably changing HalfSet’s Player() to getPlayer() or somesuch).