#include<iostream>
using namespace std;
class Time
{public:
void set_time(void)
{cin>>hour;
cin>>minute;
cin>>sec;
}
void show_time(void)
{cout<<hour<<":"<<minute<<":"<<sec<<endl;
}
private:
int hour;
int minute;
int sec;
};
Time t;
int main(0
{t.set_time();
t.show_time();
return 0;
}
将数据成员改为私人的(第二章第二题)
最新推荐文章于 2023-06-02 10:16:54 发布