keep码
度过大难,将有大成。 继续努力,终成大器。
#include <iostream>
using namespace std;
#include <string>


class Person {
public:
    //传统方式初始化
    //Person(int a, int b, int c){
    //m_A = a;
    //m_B = b;
    //m_C = c;
//}


//初始化列表方式初始化
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();


    system("pause");
    return 0;

}

 

posted on 2021-11-14 22:34  keep码  阅读(28)  评论(0编辑  收藏  举报