c++编程的问题请教关于闹钟的问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 14:43:38
/*
任务三、自己的闹钟
*/

#include <iostream>
#include <windows.h>
#include <time.h>
#include <string>
#ifdef _TIME_T_DEFINED
typedef long time_t;
#define _TIME_T_DEFINED
#endif

using namespace std;

class LiWenhao_Time
{
public:
void setDate( int newy, int newm, int newd)
{
char c;//接受-
cin >> newy >> c >> newm >> c >>newd;
m_year=newy;
m_month=newm;
m_day=newd;
}
void getDate()
{
cout << m_year << "-" <<m_month << "-" <<m_day;
}
void setTime(int newh, int newm, int news)
{
char c;//接受:
cin >> newh >> c >> newm >> c >>m_sec;
m_hour=newh;
m_min=newm;
m_sec=news;
}
void getTime()
{
cout << m_hour << ":" <

错误很多啊,我已经改好了,测试通过,有注释,自己看吧
#include <iostream>
#include <windows.h>
#include <time.h>
#include <string>
#ifdef _TIME_T_DEFINED
typedef long time_t;
#define _TIME_T_DEFINED
#endif

using namespace std;

class LiWenhao_Time
{
public:
void setDate( int &newy, int &newm, int &newd)
{
char c;//接受-
cin >> newy >> c >> newm >> c >>newd;
m_year=newy;
m_month=newm;
m_day=newd;
}
void getDate()
{
cout << m_year << "-" <<m_month << "-" <<m_day;
}
void setTime(int &newh, int &newm, int &news)//1 用引用才可以改变形参的值
{
char c;//接受:
cin >> newh >> c >> newm >> c >>news;//2 原来你这里是用m_sec的
m_hour=newh;
m_min=newm;
m_sec=news;
}
void getTime()
{
cout <<