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.
#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 ===|
In Player.h on line 13 you declare Player_Name to be of type string. However, the compiler doesn't know what a string is. It knows what an std::string is, which is probably what you want. So either declare it with std::string as the type or stick usingnamespace std; in your .h file.
C:\Users\Chay\Desktop\help\Player.h||In function 'int main()':|
C:\Users\Chay\Desktop\help\Player.h|15|error: 'std::string Player::Player_Name' is private|
C:\Users\Chay\Desktop\help\main.cpp|47|error: within this context|
C:\Users\Chay\Desktop\help\Player.h|15|error: 'std::string Player::Player_Name' is private|
C:\Users\Chay\Desktop\help\main.cpp|49|error: within this context|
||=== Build finished: 4 errors, 0 warnings ===|
Like i said i havent done this in a while so i need to be remnded i need to see code because im a visual p[erson i cant just be told to do this and that, it is 110% impossible for me to do anything without seeing code.
Like i said i havent done this in a while so i need to be remnded i need to see code because im a visual p[erson i cant just be told to do this and that, it is 110% impossible for me to do anything without seeing code.
- Do you have a book or do you only use Online resources?