7.3
#include
using namespace std;
struct box{
char marker[40];
float height;
float width;
float length;
float volume;
};
void show(const box b);
void set(box &b);
void main73()
{
cout<<”now the box valus is :”<<endl;
cout<<”b[0] is :”<<endl;
show(b[0]);
cout<<”b[1] is :”<<endl;
show(b[1]);
set(b[0]); //因为我这里是数组,数组传递的时候其实就是传递其引用!
set(b[1]);
cout<<”after set ,the box valus is:\n\n\n”;
cout<<”b[0] is :”<<endl;
show(b[0]);
cout<<”b[1] is :”<<endl;
show(b[1]);
system(“pause”);
}
void show(const box b)
{
cout<<”maker:”<<b.marker<<endl;
cout<<”height:”<<b.height<<”\nwidth:”<<b.width<<”\nlength:”<<b.length<<endl;
cout<<”volume:”<<b.volume<<endl;
}
void set(box &b)
{
b.volume=b.height*b.width*b.length;
}
—————————————————————————————————————————————————— //写的错误或者不好的地方请多多指导,可以在下面留言或者给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。 转载请注明出处:https://www.royalchen.com/ author:royalchen Email:royalchen@royalchen.com ———————————————————————————————————————————————————
- 本文作者: royalchen
- 本文链接: http://www.royalchen.com/2016/02/24/cprimerplus第六版课后编程题答案73/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!