2021-10-31

每日100!生日快乐!
拷贝构造函数
Date.h
#include
#include “string.h”

using namespace std;
class Date {
//没有限定,默认为public
int Month,Day,Yeal;
public:
Date(int m1, int d1, int y1 ){
Month = m1;
Day = d1;
Yeal = y1;
}
Date(Date &d){
Month = d.Month;
Month = d.Day;
Month = d.Yeal;
}
int M(){return Month;}
int D(){return Day;}
int Y(){return Yeal;}
};
class People{
char Name[10];
char Address[15];
Date Birthday;
public:
//初始化1
People(char *name,char *address);
//初始化2
People(char *name,char *address,int mn,int dy,int yr);
//初始化3
People(char *name,char *address,Date &d);
//输出函数
void Show_print();
};

People::People(char *name, char *address): Birthday(8,15,1999) {
strncpy(Name,name,10);
strncpy(Address,address,15);
}
People::People(char *name, char *address, int mn, int dy, int yr): Birthday(mn,dy,yr) {
strncpy(Name,name,10);
strncpy(Address,address,15);
}
People::People(char *name, char *address, Date &d): Birthday(d) {
strncpy(Name,name,10);
strncpy(Address,address,15);
}
void People::Show_print() {
cout << “姓名:” << Name << endl << “地址是:” << Address << endl;
cout << “生日是:” << Birthday.M() << “.”<< Birthday.D() << “.” << Birthday.Y() << endl;
}

Main.cpp
#include “Date.h”

int main() {
/People boy(“niuer”,“格尔木”,8,15,1999);
boy.Show_print();
/
People girl(“cuihua”,“乐都区”,11,9,2000);
girl.Show_print();
float x,y,a;

for(y = 1.5f;y > -1.5f;y -= 0.1f)
{
    for(x = -1.5f;x < 1.5f;x += 0.03f)
    {
        a = x*x + y*y - 1;
        if(a*a*a-x*x*y*y*y <=0.0f)
            printf("*");
        else
            cout << " " ;
    }
    cout << endl;
}
return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值