c++问题谢谢谁能帮我做出来
来源:百度知道 编辑:UC知道 时间:2024/05/23 12:10:56
在一个程序里实现如下要求
1.构造函数重载
2.成员函数设置缺省参数
3.使用不同的构造函数创建不同对象
4.运行符重载
5.析构函数
1.构造函数重载
2.成员函数设置缺省参数
3.使用不同的构造函数创建不同对象
4.运行符重载
5.析构函数
#include "stdio.h"
class Person
{
public:
//无参数构造函数
Person()
{
age = 20;
money = 1.0;
}
//有参数构造函数,即构造函数重载
Person(int newAge, double newMoney)
{
age = newAge;
money = newMoney;
}
//=运算符重载
Person &operator = (const Person &ref)
{
age = ref.age;
money = ref.money;
}
//析构函数
~Person()
{
}
//有默认参数的成员函数
void SetMoney(double newMoney = 10000.0)
{
money += newMoney;
}
void Show()
{