class Entity {
public:
std::string GetName() { return "Entity:"; }
};
class Player : public Entity {
private :
std::string m_name;
public :
Player(const std::string& name) : m_name(name) {}
std::string GetName() { return m_name; }
};
above is C++ class definition i'm studying currently. Everthing looks OK but i don't understand the part,
Player(const std::string& name) : m_name(name) {}
Why do I need : m_name(name)
part? what is the use of that definition?
So far what I understood is that it changes the variable m_name
to be the parameter name
of Player constructor... is that it?