I havent been programming for over a montha nd i dont want to get too rusty so im just programming to keep my knoweledge fresh but that seems to have happened anyways. I have a class and am trying to use a string in my main program but i get errors.
MAIN.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <iostream>
#include <string>
#include "Player.h"
#include <string>
/*
int x = 800;
int *pointer = &x;
cout << *pointer << endl;
*/
void Load()
{
}
void Save()
{
}
void Game()
{
}
using namespace std;
int main()
{
int choice = 0;
Player PO;
cout << "Warehouse Manager\n" << endl;
cout << "1) New Game" << endl;
cout << "2) Load Game" << endl;
cin >> choice;
if(choice == 1)
{
cout << "Welcome, what is your name?" << endl;
getline(cin, PO.Player_Name);
cout << "/nOk " << PO.Player_Name << " Lets get some info before we start" << endl;
}
if(choice == 2)
{
Game();
}
}
|
Player.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#ifndef PLAYER_H_INCLUDED
#define PLAYER_H_INCLUDED
#include <string>
class Player
{
public:
Player();
private:
int money;
string Player_Name;
};
Player::Player()
{
money = 0;
Player_Name = "";
}
#endif // PLAYER_H_INCLUDED
|
C:\Users\Chay\Desktop\help\Player.h|13|error: 'string' does not name a type|
C:\Users\Chay\Desktop\help\Player.h||In constructor 'Player::Player()':|
C:\Users\Chay\Desktop\help\Player.h|19|error: 'Player_Name' was not declared in this scope|
C:\Users\Chay\Desktop\help\main.cpp||In function 'int main()':|
C:\Users\Chay\Desktop\help\main.cpp|37|error: 'class Player' has no member named 'Player_Name'|
C:\Users\Chay\Desktop\help\main.cpp|49|error: 'class Player' has no member named 'Player_Name'|
C:\Users\Chay\Desktop\help\main.cpp|51|error: 'class Player' has no member named 'Player_Name'|
||=== Build finished: 5 errors, 0 warnings ===|