#include <iostream>
using namespace std;
class A{
private:
int n;
const double d;
public:
A():n(0),d(100.0)
{
cout << "call A()" << this << endl;
}
A(int n):n(n),d(230.0)
{
cout << "call A(int n)" << this << endl;
}
void show();
};
void A::show()
{
cout << "n=" << n << "d=" << d << endl;
}
int main()
{
A a1;
A a2(200);
a1.show();
a2.show();
return 0;
}
构造函数的初始化
最新推荐文章于 2021-03-09 22:26:26 发布