#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
class Person
{
public:
Person()
{
cout << "默认构造函数" << endl;
}
/*
Person(int a,int b,int c)
{
m_A = a;
m_B = b;
m_C = c;
cout << "有参构造" << endl;
}*/
//初始化列表 初始化数据
//构造函数后+:属性(参数),属性(参数)····
Person(int a, int b, int c) :m_A(a), m_B(b), m_C(c)
{
cout << "初始化构造列表" << endl;
}
~Person()
{
cout << "析构函数调用" << endl;
}
int m_A;
int m_B;
int m_C;
};
void test01()
{
Person(10, 20, 30);
}
int main()
{
test01();
system("pause");
return EXIT_SUCCESS;
}
C++基础学习DAY3-08初始化列表
最新推荐文章于 2024-07-23 17:04:32 发布