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文件(部分)
#ifndef PLAYERS_H#define PLAYERS_Husing namespace std;#include <string>#include <vector>#include <istream>#include <iomanip>#include "generics.h"class Player{ //line 11public: //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 country); ~Player();private: long _ID; string _firstname; string _lastname; string _country;};
game.h文件(部分)
#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;};
这里发生了什么?
解决方法 在C中,您不能将函数命名为类/ struct / typedef.你有一个名为“Player”的类,所以HalfSet类有一个名为“Player”(“Player * Player()”)的函数.您需要重命名其中一个(可能将HalfSet的Player()更改为getPlayer()或其他). 总结以上是内存溢出为你收集整理的C奇怪的编译错误:错误:从“对象”类改变“对象”的含义全部内容,希望文章能够帮你解决C奇怪的编译错误:错误:从“对象”类改变“对象”的含义所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)