主题:c++帮忙 不知道那里出错了
#include<iostream>
using namespace std;
class Date;
class Time;
void display(Date &,Time &);
class Time
{
public:
Time(int,int,int);
friend void display(Date &,Time &);
private:
int hour;
int minute;
int sec;
};
class Date
{
public:
Date(int,int,int);
friend void display(Date &,Time &);
private:
int month;
int day;
int year;
};
Time::Time(int h,int m,int s)
{
hour=h;
minute=m;
sec=s;
}
void display(Time &d,Date &d2)
{
cout<<d.hour<<":"<<d.minute<<":"<<d.sec<<endl;
cout<<d2.month<<"/"<<d2.day<<"/"<<d2.year<<endl;
}
Date::Date(int m,int d,int y)
{
month=m;
day=d;
year=y;
}
int main()
{
Time t1(10,13,56);
Date d1(12,25,2004);
display(d1,t1);
while(1);
return 0;
}
using namespace std;
class Date;
class Time;
void display(Date &,Time &);
class Time
{
public:
Time(int,int,int);
friend void display(Date &,Time &);
private:
int hour;
int minute;
int sec;
};
class Date
{
public:
Date(int,int,int);
friend void display(Date &,Time &);
private:
int month;
int day;
int year;
};
Time::Time(int h,int m,int s)
{
hour=h;
minute=m;
sec=s;
}
void display(Time &d,Date &d2)
{
cout<<d.hour<<":"<<d.minute<<":"<<d.sec<<endl;
cout<<d2.month<<"/"<<d2.day<<"/"<<d2.year<<endl;
}
Date::Date(int m,int d,int y)
{
month=m;
day=d;
year=y;
}
int main()
{
Time t1(10,13,56);
Date d1(12,25,2004);
display(d1,t1);
while(1);
return 0;
}