world_pioneer 2016-08-17 11:10 采纳率: 94.9%
浏览 1032
已采纳

函数传递结构地址的问题

#include
#include

using namespace std;

struct box
{
char maker[40];
float height;
float width;
float length;
float volume;
};

void pass_value(box);
void pass_adress(box*);

int main()
{
box* ps = new box;
ps->height = (*ps).width = ps->length = 10;
char word[] = "the world";
strcpy_s(ps->maker, word);
pass_value(*ps);
pass_adress(ps);
delete ps;
return 0;
}

void pass_value(box box_s)
{
cout << "maker: " << box_s.maker << endl;
cout << "height: " << box_s.height << endl;
cout << "width: " << box_s.width << endl;
cout << "length: " << box_s.length << endl<<endl;
}

void pass_address(box* pt)
{
cout << "volume= " << (pt->height)*(pt->width)*(pt->length) << endl;
}

图片说明

错误在哪里?求解答

  • 写回答

3条回答 默认 最新

  • AaronJ1 2016-08-17 11:37
    关注

    address少了个d

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?