c++程序设计第三版第八章

习题八

Xt8-1 #include using namespace std; class Time

{public: //成员改为公用的 int hour; int minute; int sec; }; Time t;

void set_time(void) //在main函数之前定义 {

cin>>t.hour; cin>>t.minute; cin>>t.sec; }

void show_time(void) //在main函数之前定义 {

cout<

}

int main() {set_time(); show_time();

system(\ }

Xt8-2 #include using namespace std; class Time {public:

void set_time(void) {cin>>hour; cin>>minute; cin>>sec; }

void show_time(void)

{cout<

private: int hour;

int minute; int sec; }; Time t; int main() {

t.set_time(); t.show_time();

system(\ }

Xt8-3 #include using namespace std; class Time {public:

void set_time(void); void show_time(void); private: int hour; int minute;

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4