{ int i;
for (i=0;i<10;i++) cin>>array[i]; }
void Array_max::max_value() {int i;
max=array[0]; for (i=1;i<10;i++)
if(array[i]>max) max=array[i]; }
void Array_max::show_value() {cout<<\ }
6:解法一
#include
void get_value(); float volume(); void display(); public:
float lengh; float width; float height; };
void Box::get_value()
{ cout<<\ cin>>lengh; cin>>width; cin>>height; }
float Box::volume()
{ return(lengh*width*height);}
void Box::display()
{ cout< int main() {Box box1,box2,box3; box1.get_value(); cout<<\ box1.display(); box2.get_value(); cout<<\ box2.display(); box3.get_value(); cout<<\ box3.display(); return 0; } 解法二: #include void get_value(); void volume(); void display(); public: float lengh; float width; float height; float vol; }; void Box::get_value() { cout<<\ cin>>lengh; cin>>width; cin>>height; } void Box::volume() { vol=lengh*width*height;} void Box::display() { cout< int main() {Box box1,box2,box3; box1.get_value(); box1.volume(); cout<<\ box1.display(); box2.get_value(); box2.volume(); cout<<\ box2.display(); box3.get_value(); box3.volume(); cout<<\ box3.display(); return 0; } 第三章 2: #include Date(int,int,int); Date(int,int); Date(int); Date(); void display(); private: int month; int day; int year; }; Date::Date(int m,int d,int y):month(m),day(d),year(y) { } Date::Date(int m,int d):month(m),day(d) {year=2005;} Date::Date(int m):month(m) {day=1; year=2005; } Date::Date() {month=1; day=1; year=2005; } void Date::display() {cout< int main() { Date d1(10,13,2005); Date d2(12,30); Date d3(10); Date d4; d1.display(); d2.display(); d3.display(); d4.display(); return 0; } 3: #include Date(int=1,int=1,int=2005); void display(); private: int month; int day; int year; }; Date::Date(int m,int d,int y):month(m),day(d),year(y) { } void Date::display() {cout< int main() { Date d1(10,13,2005); Date d2(12,30); Date d3(10); Date d4; d1.display(); d2.display(); d3.display(); d4.display(); return 0; } 4: #include Student(int n,float s):num(n),score(s){} void display(); private: int num; float score; }; void Student::display() {cout< int main() {Student stud[5]={ Student(101,78.5),Student(102,85.5),Student(103,98.5), Student(104,100.0),Student(105,95.5)}; Student *p=stud; for(int i=0;i<=2;p=p+2,i++) p->display(); return 0; } 5: #include Student(int n,float s):num(n),score(s){} int num; float score; };