我一直在試圖將一個結構保存在我的所有變量中,這個結構保存在一個單獨的類中。我知道這個錯誤與某種語法錯誤有關,很可能,但我不明白我做錯了什麼。傳遞結構錯誤「在'='標記之前的非限定標識」
的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