新手请教 问题出在哪里
#include<iostream>using namespace std;
class B
{
public:
B(int,int,int);
friend void display(B&);
private:
int hour;
int minute;
int sec;
};
class A
{
public:
A(int,int,int);
friend void display(A&);
private:
int year;
int month;
int day;
};
B::B(int a,int b,int c)
{
hour=a;
minute=b;
sec=c;
}
A::A(int a,int b,int c)
{
year=a;
month=b;
day=c;
}
void display(A&t)
{
cout<<t.year<<"/"<<t.month<<"/"<<t.day<<endl;
}
void display(B&t)
{
cout<<t.hour<<"/"<<t.minute<<"/"<<t.sec<<endl;
int main()
{
A t1(2001,2,2);
B t2(12,2,22);
display(t1);
display(t2);
return 0;