c 2b 2b class member initializer list

Solutions on MaxInterview for c 2b 2b class member initializer list by the best coders in the world

showing results for - "c 2b 2b class member initializer list"
Emanuele
21 Sep 2017
1#include <iostream>
2class Entity {
3private : 
4	std::string m_Name;
5	int m_Score;
6	int x, y, z;
7public:
8	Entity()
9		:m_Name("[Unknown]"),m_Score(0),x(0),y(0),z(0)//initialize in the order of how var are declared
10	{
11	}
12	Entity (const std::string& name) 
13		:m_Name(name)
14	{}
15	const std::string& GetName() const { return m_Name; };
16};
17int main()
18{
19	Entity e1;
20	std::cout << e1.GetName() << std::endl;
21	Entity e2("Caleb");
22	std::cout << e2.GetName() << std::endl;
23	std::cin.get();
24}