3-11

来源:互联网 发布:c语言大小写转换用str 编辑:程序博客网 时间:2024/06/05 15:55
#include <iostream>  using namespace std;  class Time;  class Date  {  public:      Date(int ,int ,int);      void display(Time &);  private:      int day;      int month;      int year;  };  Date::Date(int d,int m,int y)  {   int day=d;   int month=m;   int year=y;  }  class Time  {  public:      Time(int,int,int);      friend void Date::display(Time &);  private:      int hour;      int minute;      int sec;  };  Time::Time(int h,int m,int s)  {   hour=h;   minute=m;   sec=s;  }  void Date::display(Time &t)  {   cout<<day<<" "<<month<<" "<<year<<endl;   cout<<t.hour<<" "<<t.minute<<" "<<t.sec<<endl;  }  int main()  {   Time t(10,13,56);   Date d(12,25,2004);   d.display(t);   return 0;  }  


0 0
原创粉丝点击