1、1.1编写一个基于对象的程序,要求:(1)定义一个时间类 Time,类内有私有数据成员 hour(小时)、minute(分钟) 、sec(秒) ,公有成员函数 set_time()、show_time()。(2)set_time()函数和 show_time()函数在类内定义。set_time()作用是从键盘输入时间、分钟、秒的值,show_time()的作用是在屏幕上显示时间、分钟、秒的值。(3)在 main()函数定义 Time 类的对象 t1,并调用set_time()函数给时间赋值,调用 show_time()函数输出时间的值。#include using namespace std;
2、class Timepublic:void set_time()cinhour;cinminute;cinsec;void show_time()coutusing namespace std;class Boxpublic:void get_value();void volume();private:float lengh;float width;float height;void Box:get_value() coutlengh;cinwidth;cinheight;void Box:volume() coutusing namespace std;class Array_maxpubl
3、ic:void set_value();void max_value();private:int array10;int max;void Array_max:set_value() int i;for (i=0;iarrayi;void Array_max:max_value()int i;max=array0;for (i=1;imax) max=arrayi;coutusing namespace std;class Complexpublic:Complex()real=0;imag=0;Complex(double r,double i)real=r;imag=i;Complex o
4、perator + (Complex void display();private:double real;double imag;Complex Complex:operator + (Complex c.real=real+c2.real;c.imag=imag+c2.imag;return c;void Complex:display()coutclass Complexpublic:Complex()real=0;imag=0;Complex(double r)real=r;imag=0;Complex(double r,double i)real=r;imag=i;friend Co
5、mplex operator+ (Complex void display();private:double real;double imag;Complex operator+ (Complex void Complex:display()coutusing namespace std;class Circlepublic:void get_value();void volume();private:float radius;void Circle:get_value() coutradius;void Circle:volume() coutusing namespace std;clas
6、s Datepublic:void set_date();void show_date();private: int year;int month;int day;void Date:set_date()cinyear;cinmonth;cinday;void Date:show_date()coutusing namespace std;class Studentpublic:void get_value()cinnumnamesex;void display( )coutageaddr;void display_1() display();cout“age: “ageendl; cout“address: “addrendl; private:int age;char addr30;