#include <iostream>
using namespace std;
class Parent{
int n;
public:
Parent():n(0)
{
cout << "Parent()" << endl;
}
Parent(int n):n(n)
{
cout << "Parnet(" << n << ")" << endl;
}
~Parent()
{
cout << "~Parent()" << endl;
}
};
class Child : public Parent{
double d;
public:
Child():d(0)
{
cout << "Child()" << endl;
}
Child(double d):d(d),Parent(50)
{
cout << "Child(" << d << ")" << endl;
}
~Child()
{
cout << "~Child()" << endl;
}
};
int main()
{
Child c1(100);
return 0;
}
继承 构造函数
最新推荐文章于 2024-05-04 10:00:08 发布