I got a problem with this code. here it is.
Show.h
Show.cppCode://Menu class class Show { public: void CharStats(); void WhatToDo(); private: };
Code:#include "Library.h" //Char stats void Show::CharStats() { cout <<"Name: "<<player.getName(); }
Player.h
Player.cppCode://Player class class Player { public: string getName(); void setName(string playername); private: string pName; };
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:
Now, what im trying to do is acessing it from the Show.cpp (Show class) function called charstats.Code://Create the player Player player;
The charstats will actually print the player.getName() on the screen...How am i able to acess player.getName from there?



LinkBack URL
About LinkBacks



