关于结构体按地址传递给函数问题,,程序求纠错
#include<iostream>using namespace std;
struct box{
char maker[40];
float height;
float width ;
float length;
float volume;
};
void show(box);
float tiji(box*);
int main()
{
box a={"shandong",3,3,3,0};
cout<<"the tiji is "<<tiji[&a]<<endl;
show(a);
return 0;
}
void show(box a )
{
cout<<"the maker is "<<a.maker<<endl;
cout<<"the height is "<<a.height <<endl;
cout<<"the width is "<<a.width <<endl;
cout<<"the length is "<<a.length <<endl;
cout<<"the volume is"<<a.volume <<endl;
}
float tiji(box* pa)
{
pa->volume =pa->height *pa->length *pa->width ;
return pa->volume ;
}