Working with classes here and I feel like the use of the same name in different parts of the code isn't good practice. Some times name is "Name" and other times it's "name" and the same with mana and health. I'll provide my main.cpp, player.cpp, and player.h below. Using my current names and setup. could you suggest a more appropriate alternative for these names? They even confuse me and I'm the one that wrote it.
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "Player.h"
#include <conio.h>
#include <iostream>
#include <string>
std::string name;
int health = 0, mana = 0;
int main()
{
Player Player1(name, health, mana);
return 0;
}
It looks fine to me (I just dislike how you store it as newName... it should be simply name, change the constructor's parameters instead).
Personally, lately I only follow the g_ and m_ convention:
Globals begin with g_ (g_name) and class members begin with m_ (m_name).
Occasionally I do the same for parameters (p_) and locals (l_).
Your constructor would then become: Player::Player(std::string const& p_name, int p_health, int p_mana) : m_name(p_name), m_health(p_health), m_mana(p_mana) {}
(Note: I added a const& in the constructor. It helps to avoid expensive object copies).