#include <iostream>
using namespace std;
struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};
void func1(box a);
void func2(box * ar);
int main() {
box ar={
"canon",
12.3,
4.2,
6.7,
9.3
};
func1(ar);
func2(&ar);
cout<<"\nNew struct:"<<endl;
func1(ar);
return 0;
}
void func1(box a)
{
cout<<"maker: "<<a.maker<<endl;
cout<<"height: "<<a.height<<endl;
cout<<"width: "<<a.width<<endl;
cout<<"length: "<<a.length<<endl;
cout<<"volume: "<<a.volume<<endl;
}
void func2(box * ar)
{
ar->volume=ar->height*ar->width*ar->length;
}
C++primer plus 6th 第7章7.3编程答案
最新推荐文章于 2024-10-31 09:04:32 发布