我编写了一个代码,使用构造函数将时间转换为分钟和秒。在输出中,我以秒为单位获得时间,但它没有以分钟为单位显示时间,并且无法弄清楚我的错误,所以任何人都可以帮助我......
#include<iostream>
using namespace std;
class Time
{
public:
Time(int);
Time(float);
};
Time::Time(int t)
{
cout << "Time in seconds: " << t*60*60 << "\n";
}
Time::Time(float t)
{
cout << "Time in Minutes: " << int(t*60) << "\n";
}
int main()
{
int hr;
cout << "Enter the time in Hours: ";
cin >> hr;
Time t1(hr);
Time t2(float(hr));
}