By making those members private, what you've done is ensured that those members cannot be accessed directly (except by methods of your Player class). This is true whether its a pointer or not.
So, this will fail:
Player PlayerOne("MrCpaw", 100, 5, 0, 0);cout << PlayerOne.PlayerName;
And so will this:
Player *PlayerOne = new Player("MrCpaw", 100, 5, 0, 0);cout << PlayerOne->PlayerName;
In order to access the player name for this purpose, you will actually need to create a method in your Player class, called GetPlayerName or something similar, in the public scope, and have it return the string:
class Player // Player Class{private: string PlayerName; // Player Name int PlayerHealth; // Player Health int PlayerDamage; // Player Damage Power int PlayerGold; // Gold Obtained int PlayerExp; // Experince Obtainedpublic: // Constructor Player(string PlayerName_TEMP, int PlayerHealth_TEMP, int PlayerDamage_TEMP, int PlayerGold_TEMP, int PlayerExp_TEMP): PlayerName(PlayerName_TEMP), PlayerHealth(PlayerHealth_TEMP), PlayerDamage(PlayerDamage_TEMP), PlayerGold(PlayerGold_TEMP), PlayerExp(PlayerExp_TEMP) {} // Methods GetPlayerName() { return PlayerName; }};
And then, to print the name out, you would do this:
Player PlayerOne("MrCpaw", 100, 5, 0, 0);cout << PlayerOne.GetPlayerName();
You may be confused as to why C++ programmers bother to do this. I admit I am not as well-versed in OOP principles as I'd like to be and so my answer will probably not be sufficient, but here it goes: it's often a good practice to do this because it provides separation between the interface of your class and the implementation of your class.
Often times, from the perspective of other programmers who are using the class you wrote, it's often easier to deal with simple method calls than it is to try to access the data directly. This is hard to see what an example as trivial as this, because PlayerOne.PlayerName seems just as easy, if not easier, than PlayerOne.GetPlayerName(). However, for lots of data, it's not.
Not only that, but by forcing the user of your class to go through a method like this (it's called an accessor method), you give yourself the ability to change the way that the data is set up in your class without breaking all of the code.
For example (and this is a terrible example that would never happen in real life, but bear with me), but suppose that you wanted to change PlayerName to a character array instead of a string object. Imagine doing this after your game code already contains a couple hundred references to PlayerName, like this:
std::string strValue = PlayerOne.PlayerName.substr(5);
Now, if you changed PlayerName to a character array instead of a string object, then the above line of code, and every line of code like it in your whole project, would result in a compile error.
On the other hand, if those lines of code looked something like this:
std::string strValue = PlayerOne.GetPlayerName().substr(5);
Then all you would have to do, after changing PlayerName to a character array, is change the GetPlayerName() method as follows:
GetPlayerName() { return string(PlayerName); }
Now, GetPlayerName() returns PlayerName in string form even though its a character array, and all of your other code compiles as normal.
This example is silly, but it basically conveys the point that, by having users of your class go through accessor methods and such, you provide an interface to your class, and this interface sort of acts like a layer of separation...creating a sort of "outside shell" to your class, which allows you to make changes to the internal details of your class, and as long as you update the interface to handle it, you allow users of your class to remain ignorant of the changes.