题目给答案出错,谁知道怎么改

实际编译会通不过,怎么改,求大神告知

实际编译会通不过,怎么改,求大神告知
2015-10-28
哈哈,仔细看题目啊底下是我的代码,单元巩固的调试那里没有报错,仅供参考
#include <iostream>
using namespace std;
class Watch;
/**
* 定义Time类
* 数据成员:m_iHour, m_iMinute,m_iSecond
* 成员函数:构造函数
* 友元类:Watch
*/
class Time
{
// 友元类
friend Watch;
public:
Time(int hour, int min, int sec)
{
m_iHour = hour;
m_iMinute = min;
m_iSecond = sec;
}
public:
int m_iHour;
int m_iMinute;
int m_iSecond;
};
/**
* 定义Watch类
* 数据成员:m_tTime
* 成员函数:构造函数
* display用于显示时间
*/
class Watch
{
public:
Watch(Time &time):m_tTime(time.m_iHour,time.m_iMinute,time.m_iSecond)
{
}
void display()
{
cout << m_tTime.m_iHour << endl;
cout << m_tTime.m_iMinute << endl;
cout << m_tTime.m_iSecond << endl;
}
public:
Time m_tTime;
};
int main()
{
Time t(6, 30, 20);
Watch w(t);
w.display();
return 0;
}举报