首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

异常提示collect2: error: ld returned 1 exit status如何解决

2013-01-05 
错误提示collect2: error: ld returned 1 exit status怎么解决本人做了一个课后练习题 代码如下编译的时候

错误提示collect2: error: ld returned 1 exit status怎么解决
本人做了一个课后练习题 代码如下  编译的时候出现
[jli52@1005-20 chap_7]$ g++ -g struMeth.cpp -o struMeth
/tmp/ccNELBUx.o: In function `main':
/home/122/j/jli52/Documents/chap_7/struMeth.cpp:51: undefined reference to `calculate(box*)'
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
哪位大神能给解答一下  谢谢啦
还有一个问题 有个练习题  不太明白 有个结构candyBar 包含三个成员 分别是 名称 重量  和卡路里 要求用new来动态分配数组 而不是声明一个包含三个元素的candyBar数组  我不明白的是 如果是用数组的话 数组只能储存同一个类型的数据  但是这个结构中的数据类型是不同的  如何用数组去储存这些数据



#include<iostream>
#include<cmath>


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


const void show(box info);
box calculate (box *info);




const void show(box info,box info1)
{
  using namespace std;
  cout<<"The maker of the box is: "<<info1.maker<<endl;
  cout<<"The height of the box is: "<<info1.height<<endl;
  cout<<"The length of the box is: "<<info1.length<<endl;
  cout<<"The volume of the box is: "<<info.volume<<endl;
 
}


box caculate (box *info)
{
  box result;
  result.volume=info->height*info->length*info->width;
  return result;
}


int main()
{
  using namespace std;
  box info;
  box result;
  cout<<"Please enter the maker, height, width, and length of the box respectly"
      <<endl;
  cin.getline(info.maker,40);
  cin>>info.height;
  cin>>info.width;
  cin>>info.length;
  result=calculate(&info);
  show(result,info);
  return 0;
}




[解决办法]
box caculate (box *info) 
->
box calculate (box *info) 

热点排行