我一直在试图将一个结构保存在我的所有变量中,这个结构保存在一个单独的类中。我知道这个错误与某种语法错误有关,很可能,但我不明白我做错了什么。传递结构错误“在'='标记之前的非限定标识”
的main.ccp是:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include "running.h"
using namespace std;
int main()
{
//------Class Objects---------
running runObj;
//----------Vars--------------
char saveGame = 'N';
struct gameVar
{
int correctGuesses; // These vars need to be reset for each new game.
int Lives;
int rowCorrect;
int highScore;
char anotherGame;
} values;
values.highScore = 12;
values.anotherGame = 'Y';
//--------Game Loop-----------
// int highScore2 = runObj.readHighScore();
while (values.anotherGame = 'Y')
{
struct gameVar = runObj.processGame(gameVar);
struct gameVar = runObj.afterText(gameVar);
gameVar values;
values.anotherGame;
}
cout << endl << "-------------------------------------------------------" << endl;
cout << "Would you like to save your high score? Y/N" << endl;
cin >> saveGame;
if(saveGame == 'Y')
{
runObj.saveHighScore(gameVar);
}
return 0;
}
我的头文件是:
#ifndef RUNNING_H
#define RUNNING_H
class running
{
public:
struct gameVar processGame(struct gameVar);
void saveHighScore(struct hs);
int readHighScore();
struct gameVar afterText(struct gameVar);
};
#endif // RUNNING_H
谢谢您的帮助!我认为我现在对结构有更加坚定的把握,现在结构正在工作。再次感谢你! – ponger3d 2013-02-08 21:20:42