在项目中频繁见到,写个小程序,熟悉一下:

#include <iostream>
using namespace std;

class A
{
public:
	int a;
	
public:
	A()
	:a(0)
	{}

	A(int x)
	:a(x)
	{}
};

int main()
{
	A obj0;
	A obj1(1);
	cout << obj0.a << endl;
	cout << obj1.a << endl;

	return 0;
}

 


本文转载:CSDN博客