补一

xiaoxiao2021-02-28  230

一、问题及代码。

#include<iostream> using namespace std; class Date;  class Time   {   public:       Time(int,int,int);       void add_a_second(Date &);       void display(Date &);  friend class Date; private:       int hour;       int minute;       int sec; int month;       int day;       int year;   };   class Date   {   public:       Date(int,int,int);  friend class Time; private:       int month;       int day;       int year;   };      int main( )   {       Time t1(23,59,32);       Date d1(12,31,2013);         for(int i=0; i<=100; i++)       {           t1.add_a_second(d1);           t1.display(d1);       }       return 0;   }   Date::Date(int m,int d,int y) { month=m; day=d; year=y; } Time::Time(int h,int a,int s) { hour=h; minute=a; sec=s; } void Time:: add_a_second(Date &d) { if(sec+1>=60&&minute>=59&&hour>=23&&day>=30&&month>=12) { sec=sec`; minute=(minute+1)`; hour=(hour+1)$; day=(day+1)0; month=(month+1); year=year+1; } else { sec=(sec+1)`; minute=(minute+1)`; hour=(hour+1)$; day=day;         month=month;    year=year; } } void Time::display(Date &d) { cout<<d.year<<"/"<<d.month<<"/"<<d.day<<" "; cout<<hour<<":"<<minute<<":"<<sec<<" "<<endl; }

二、运行结果。

三、心得体会。

结果还是不对,很多的提示都不知道是什么错误,对于一些概念性的东西还是不能很好的理解,代码中有些问题分析也不全面,但是不知道怎样完善。

四、知识点总结。

1、对友函数的理解和应用。

2、对问题的多方面思考。

3、对以前的知识点的运用。

转载请注明原文地址: https://www.6miu.com/read-85428.html

最新回复(0)