类和对象-对象特性-初始化列表

类和对象-对象特性-初始化列表

class Person
{
	public:
		Person(int a, int b ,int c) :m_A(a), m_B(b),m_C(c)
		{
		}

		void PrintPerson() 
		{
			cout << "mA:" << m_A << endl;
			cout << "mB:" << m_B << endl;
			cout << "mC:"<< m_C << endl;
		}
	private:
		int m_A;
		int m B;
		int m_C;

};
int main() 
{
	Person p(1,2,3);
	p.PrintPerson();
}

posted @ 2023-02-23 10:57  share0956  阅读(24)  评论(0)    收藏  举报