Question: C++ help, TCHAR* is not declared but I don't know where I need to declare it. That is just one of the 460 errors this
C++ help, TCHAR* is not declared but I don't know where I need to declare it. That is just one of the 460 errors this code is throwing. I am just learning C++ so this has me very confused.
Currently, there is a test program that calls a players class. The program asks the player for a name and then gives options on what happens next. The only option available is to quit. Add an additional option and supporting code in the player header that will allow the player to input a preferred console type. After the player inputs a preferred console type, be sure to redisplay it.
//Main TextAdventure.cpp
// Chapter7-TextAdventure.cpp : Defines the entry point for the console application. //
#include "stdafx.h" #include "Player.h" #include "GameLoop.h"
int _tmain(int argc, _TCHAR* argv[]) { Game game; game.RunGame();
return 0; }
//GameLoop.cpp
#include "GameLoop.h" #include
using namespace std;
void Game::WelcomePlayer() { cout << "Welcome to Text Adventure!" << endl << endl; cout << "What is your name?" << endl << endl;
string name; cin >> name; m_player.SetName(name);
cout << endl << "Hello " << m_player.GetName() << endl; }
void Game::GivePlayerOptions() const { cout << "What would you like to do? (Enter a corresponding number)" << endl << endl; cout << "1: Quit" << endl << endl; }
void Game::GetPlayerInput(string& playerInput) const { cin >> playerInput; }
PlayerOptions Game::EvaluateInput(string& playerInput) const { PlayerOptions chosenOption = PlayerOptions::None;
if (playerInput.compare("1") == 0) { cout << "You have chosen to Quit!" << endl << endl; chosenOption = PlayerOptions::Quit; } else { cout << "I do not recognise that option, try again!" << endl << endl; }
return chosenOption; }
void Game::RunGame() { WelcomePlayer();
bool shouldEnd = false; while (shouldEnd == false) { GivePlayerOptions();
string playerInput; GetPlayerInput(playerInput);
shouldEnd = EvaluateInput(playerInput) == PlayerOptions::Quit; } }
//GameLoop.H header file
#pragma once
#include "Player.h" #include "PlayerOptions.h"
class Game { private: Player m_player;
void WelcomePlayer(); void GivePlayerOptions() const; void GetPlayerInput(std::string& playerInput) const; PlayerOptions EvaluateInput(std::string& playerInput) const; public:
void RunGame(); };
//Player.H header file
#pragma once
#include
class Player { private: std::string m_name;
public: Player() { }
void SetName(const std::string& name) { m_name = name; }
const std::string& GetName() const { return m_name; } };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
