I got a problem with this code. here it is.
Show.h
Code:
//Menu class
class Show
{
public:
void CharStats();
void WhatToDo();
private:
};
Show.cpp
Code:
#include "Library.h"
//Char stats
void Show::CharStats()
{
cout <<"Name: "<<player.getName();
}
Player.h
Code:
//Player class
class Player
{
public:
string getName();
void setName(string playername);
private:
string pName;
};
Player.cpp
Code:
#include "Library.h"
//Player Name
string Player::getName()
{
return pName;
}
void Player::setName(string playername)
{
pName = playername;
}
Okay, now, in main.cpp, i have created the class(the object).
I've written this:
Code:
//Create the player
Player player;
Now, what im trying to do is acessing it from the Show.cpp (Show class) function called charstats.
The charstats will actually print the player.getName() on the screen...How am i able to acess player.getName from there?