我正在做一个大学项目,我必须在其中实现一个简单的拼字游戏。
我有一个player
类(包含一个分数和玩家的手,形式为 astd::string
和一个score
类(包含名称和数字 ( int
) 分数)。
的Player
成员函数之一是Score getScore()
,它为该玩家返回一个 Score 对象。但是,我在编译时收到以下错误:
player.h(27) : error C2146: syntax error : missing ';' before identifier 'getScore'
player.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(27) : warning C4183: 'getScore': missing return type; assumed to be a member function returning 'int'
player.h(35) : error C2146: syntax error : missing ';' before identifier '_score'
player.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
这里分别是第 27 和 35 行:
Score getScore(); //defined as public
(...)
Score _score; //defined as private
我知道编译器无法识别Score
为有效类型......但是为什么呢?我Score.h
在开头正确地包括了player.h
:
#include "Score.h"
#include "Deck.h"
#include <string>
我有一个默认构造函数Score
定义在Score.h
:
Score(); //score.h
//score.cpp
Score::Score()
{
_name = "";
_points = 0;
}
任何输入将不胜感激!
谢谢你的时间,
弗朗西斯科
编辑:
根据要求, score.h 和 player.h: http ://pastebin.com/3JzXP36i http://pastebin.com/y7sGVZ4A