【发布时间】:2020-03-14 19:32:10
【问题描述】:
我有两个课程 Instructor 和 Game。
Instructor.h
class Instructor
{
int instrID;
public:
Instructor();
void showGameStatus();
int createGame();
vector<int> createGames(int numberOfGames);
};
游戏.h:
class Game {
private:
int gID;
int instrID;
int pFactID;
public:
Game() { // default constructor
gID = 0;
instrID = 0;
pFactID = 0;
};
这些在 Instructor.cpp 中
void Instructor::showGameStatus()
{
}
int Instructor::createGame()
{
Game g;
}
CreateGame() 初始化游戏。我希望在调用 showGameStatus() 时可以打印出之前初始化的游戏 g 的所有属性(例如 gId、InstrId)等。
是否可以通过其他方法访问游戏 g 的属性?
【问题讨论】: