构造函数与初始化列表
#include<bits/stdc++.h> using namespace std; class person { public: person(int a,int b,int c):m_a(a),m_b(b),m_c(c) { } int m_a; int m_b; int m_c; }; void test() { person p(10,20,30); cout << "p ma = " << p.m_a << endl; cout << "p mb = " << p.m_b << endl; cout << "p mc = " << p.m_c << endl; } int main() { test(); return 0; }