1. #include<iostream>
    2. using namespace std;
    3. //深拷贝与浅拷贝
    4. class person {
    5. public:
    6. //person() {//无参构造函数(默认构造函数)
    7. // cout << "person的无参构造函数调用" << endl;
    8. //}
    9. //person(int a, int b, int c) {//有参构造函数
    10. // m_a = a;
    11. // m_b = b;
    12. // m_c = c;
    13. // cout << "person的有参构造函数调用" << endl;
    14. //}
    15. person(int a, int b, int c):m_a(a),m_b(b),m_c(c){//初始化列表
    16. }
    17. int m_a;
    18. int m_b;
    19. int m_c;
    20. };
    21. void test() {
    22. person p(30,20,10);
    23. cout << p.m_a << endl;
    24. cout << p.m_b << endl;
    25. cout << p.m_c << endl;
    26. }
    27. int main() {
    28. test();
    29. return 0;
    30. }