第一题改写程序:
#include
using namespace std;
class Time //定义Time类
{public:
void input()
{
cin >> hour >> minute >> sec;
}
void display()
{
cout << hour << minute << sec;
}
private:
int hour;
int minute;
int sec;
};
int main( )
{ Time t1;
t1.input();
t1.display();
system("pause");
return 0;
}
第二题:成员函数set_value如下:
void student::set_value(int _num,char *_name,char _sex)
{
num = _num;
strcpy(name,_name);
sex = _sex;
}
第三题:
class Column
{
Colume(){}
Colume(float _length,float _width,float _height)
{
length =_length;
width = _width;
height = _height;
}
public:
float cal_volume()
{
return length*width*height;
}
void display()
{
cout << cal_volume() << endl;
}
private:
float length;
float width;
float height;
};
主函数你自己写吧