定义一个时间类Time,包含3个保护数据成员Hour(小时),Minute(分钟),second(秒)以及两个公有成员函数
定义一个时间类Time,包含3个保护数据成员Hour(小时),Minute(分钟),second(秒)以及两个公有成员函数SetTime()用来为对象设置时间,ShowT...
定义一个时间类Time,包含3个保护数据成员Hour(小时),Minute(分钟),second(秒)以及两个公有成员函数SetTime()用来为对象设置时间,ShowTime()用来输出显示时间。
定义该类的构造函数,初始化对象的Hour,Minute和Second;
主函数中定义两个对象,时间分别为15点38分42秒和3点4分5秒,并且输出。 展开
定义该类的构造函数,初始化对象的Hour,Minute和Second;
主函数中定义两个对象,时间分别为15点38分42秒和3点4分5秒,并且输出。 展开
4个回答
展开全部
#include <iostream>
using namespace std;
class Time
{
protected:
int Hour;
int Minute;
int second;
public:
Time();
void SetTime(int Hour,int Minute,int second);
void ShowTime();
};
Time::Time()
{
Hour = 0;
Minute = 0;
second = 0;
}
void Time::SetTime(int Hour,int Minute,int second)
{
this->Hour = Hour;
this->Minute = Minute;
this->second = second;
}
void Time::ShowTime()
{
cout<<枯岩Hour<<":"<<没洞御颤友Minute<<":"<<second<<endl;
}
int main()
{
Time T1,T2;
T1.SetTime(15,38,42);
T2.SetTime(3,4,5);
T1.ShowTime();
T2.ShowTime();
return 0;
}
using namespace std;
class Time
{
protected:
int Hour;
int Minute;
int second;
public:
Time();
void SetTime(int Hour,int Minute,int second);
void ShowTime();
};
Time::Time()
{
Hour = 0;
Minute = 0;
second = 0;
}
void Time::SetTime(int Hour,int Minute,int second)
{
this->Hour = Hour;
this->Minute = Minute;
this->second = second;
}
void Time::ShowTime()
{
cout<<枯岩Hour<<":"<<没洞御颤友Minute<<":"<<second<<endl;
}
int main()
{
Time T1,T2;
T1.SetTime(15,38,42);
T2.SetTime(3,4,5);
T1.ShowTime();
T2.ShowTime();
return 0;
}
展开全部
#include<iostream>
using namespace std;
class Time
{
public:
Time(int h=0,int m=0,int s=0);
void SetTime(int h1,int m1,int s1);
void ShowTime();
private:
int Hour;
int Minute;
int Second;
};
int main()
{
Time t1,t2;
t1.SetTime(15,38,42);
t2.SetTime(3,4,5);
t1.ShowTime();
t2.ShowTime();
return 0;
}
Time::Time(int h,int m,int s):Hour(h),Minute(m),Second(s){}
void Time::SetTime(int h1,int m1,int s1)
{
Hour=h1;
Minute=m1;
Second=s1;
}
void Time::ShowTime()
{
cout<<Hour<<"正颤:"<<Minute<<歼慧"举改败:"<<Second<<endl;
}
using namespace std;
class Time
{
public:
Time(int h=0,int m=0,int s=0);
void SetTime(int h1,int m1,int s1);
void ShowTime();
private:
int Hour;
int Minute;
int Second;
};
int main()
{
Time t1,t2;
t1.SetTime(15,38,42);
t2.SetTime(3,4,5);
t1.ShowTime();
t2.ShowTime();
return 0;
}
Time::Time(int h,int m,int s):Hour(h),Minute(m),Second(s){}
void Time::SetTime(int h1,int m1,int s1)
{
Hour=h1;
Minute=m1;
Second=s1;
}
void Time::ShowTime()
{
cout<<Hour<<"正颤:"<<Minute<<歼慧"举改败:"<<Second<<endl;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <iostream>
using namespace std;
class Time
{
protected:
int Hour;
int Minute;
int second;
public:
Time(){Hour=0;Minute=0;second=0;}
void SetTime(int a,int b,int c){Hour=a;Minute=b;second=c;}
void ShowTime(){cout<<Hour<<燃桥":"<< Minute<皮碰猛<":"<<second<<吵橡endl;}
};
int main()
{
Time t1,t2;
t1.SetTime(15,38,42);
t2.SetTime(3,4,5);
t1.ShowTime();
t2.ShowTime();
return 0;
}
using namespace std;
class Time
{
protected:
int Hour;
int Minute;
int second;
public:
Time(){Hour=0;Minute=0;second=0;}
void SetTime(int a,int b,int c){Hour=a;Minute=b;second=c;}
void ShowTime(){cout<<Hour<<燃桥":"<< Minute<皮碰猛<":"<<second<<吵橡endl;}
};
int main()
{
Time t1,t2;
t1.SetTime(15,38,42);
t2.SetTime(3,4,5);
t1.ShowTime();
t2.ShowTime();
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#77
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |