I can't figure it out.
#include <iostream>
#include "GameMenu.h"
#include "PlayerInfo.h"
using namespace std;
GameMenu::GameMenu() {
}
void GameMenu::display() {
cout << "-----------------------------------------------------------------" << endl;
cout << "Welcome to \"Hot or Cold\"" << endl;
cout << "-----------------------------------------------------------------" << endl;
cout << "OBJECTIVE:\t\tGuess the number in fewest number of guesses." << endl;
cout << "SCORING:\tThe fewer your guesses, the greater your score." << endl;
cout << "MAX SCORE:\t200 points." << endl;
cout << "\t\tYou start with a free 10 points :D\n\n" << endl;
PlayerInfo pi;
pi.setupPlayerInfo();
}
void GameMenu::terminateGame() {
}
#include <iostream>
#include "PlayerInfo.h"
#include "FileController.h"
;using namespace std;
void setupPlayerInfo() {
string userName;
cout << "\nPlease provide your name. (Names are case sensitive)." << endl;
getline(cin, userName);
cout << "\nYou input '" << userName << "'. Continue using this name?" << endl;
cout << "1 - Yes" << endl;
cout << "2 - No " << endl;
int choice;
cin.clear();
cin >> choice;
switch(choice) {
case 1:
system("cls");
{
bool userExists = false;
FileController fc;
string tmp;
while (!fc.getInFile().eof()) {
fc.getInFile() >> tmp;
if (tmp == userName) {
cout << "Welcome back "<< userName << "!\n\n" << endl;
userExists = true;
fc.getInFile().close();
break;
}
}
if (!userExists) {
cout << "Great! Let's begin!\n\n" << endl;
}
}
break;
case 2:
setupPlayerInfo();
break;
default:
cout << "\nInvalid Input." << endl;
setupPlayerInfo();
break;
}
}
PlayerInfo::PlayerInfo() {
}
void PlayerInfo::setPlayerName(string name) {
playerName = name;
}
string PlayerInfo::getPlayerName() {
return playerName;
}
You'll notice that I have a ';' before the namespace declaration. I don't know why but my code won't run if it's not there. It gives me a "error C2143: syntax error : missing ';' before 'using'" error -.-
Also, why won't it let me call the setPlayerName function within PlayerInfo?
Sorry for the newbie questions, I just started a class using C++...