c语言黄建灯第七章答案,求各路大虾的指教,为什么程序调试没错,结果、、、、...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include

#include

#include

class time

{

private:

int hour,minute,second;

public:

time(int h,int m,int s)

{

hour=h;

minute=m;

second=s;

}

void settime(int h,int m,int s);

void gettime(char *);

};

void time::settime(int h,int m,int s)

{

hour=h;

minute=m;

second=s;

}

void time::gettime(char *e)

{

char t[20];

_itoa(hour,e,10);

strcat(e,"/"); _itoa(minute,t,10);

strcat(e,t);

strcat(e,"/"); _itoa(second,t,10);

strcat(e,t);

}

class date

{

private:

int year,month,day;

public:

date(int y,int mo,int d)

{

year=y;

month=mo;

day=d;

}

void setdate(int y,int mo,int d);

void getdate(char *s);

};

void date::setdate (int y,int mo,int d)

{

year=y;

month=mo;

day=d;

}

void date::getdate(char *s)

{

char t[20];

_itoa(year,s,10);

strcat(s,"/"); _itoa(month,t,10);

strcat(s,t);

strcat(s,"/"); _itoa(day,t,10);

strcat(s,t);

}

class datetime:public date,public time

{

public:

datetime(int y,int mo,int s,int h,int m,int d):date(y,mo,d),time(h,m,s){}

void setdatetime();

void getdatetime(char *a,char *b);

};

void datetime::setdatetime()

{

void setdate(int y,int mo,int d);

void settime(int h,int m,int s);

}

void datetime::getdatetime(char* a,char* b)

{

void getdate(char *a);

void gettime(char *b);

}

void main()

{

char h[100],e[100];

datetime dt(1990,7,15,1,23,45);

dt.getdatetime(h,e);

cout<

cout<

}

此程序调试都没错,结果是这一连串的字,求各位高人多多指点。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值