#include<iostream>
#include<string>
using namespace std;
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) {
}
int m_A;
int m_B;
int m_C;
};
void test01() {
Person p(10, 20, 30);
//Person p;
cout << p.m_A << endl;
cout << p.m_B << endl;
cout << p.m_C << endl;
}
int main() {
test01();
return 0;
}
类的初始化列表
最新推荐文章于 2023-07-31 16:01:38 发布