读书人

编译C++出现的异常

发布时间: 2012-09-01 09:33:02 作者: rapoo

编译C++出现的错误

C/C++ code
#ifndef COORDIN_H_#define COORDIN_H_struct polar{    double distance;    double angle;};struct rect{  double x;  double y;};polar rect_to_polar(rect xsypos);void show_polar(polar dapos);#endif

C/C++ code
#include"stdafx.h"#include<iostream>#include<cmath>#include"coordin.h"using namespace std;polar rect_to_polar(rect xypos){    polar answer;        answer.distance = sqrt(xypos.x * xypos.x + xypos.y * xypos.y );    answer.angle = atan2(xypos.x,xypos.y);    return answer;}void show_polar(polar dapos){  const double Rad_to_deg = 57.29577951;  cout << "distance= " << dapos.distance;  cout << ",angle= " << dapos.angle *  Rad_to_deg;   cout << "degree\n";}

C/C++ code
// Different.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include<iostream>#include "coordin.h"using namespace std;int main(){   rect rplace;   polar pplace;   cout << "enter x and y" ;   while(cin>>rplace.x>>rplace.y)   {       pplace = rect_to_polar(rplace);       show_polar(pplace);       cout << "enter next one(q to quit):";   }   cout << "end\n";   return 0;   system("pause");}



错误1error LNK2019: 无法解析的外部符号 "void __cdecl show_ploar(struct polar)" (?show_ploar@@YAXUpolar@@@Z),该符号在函数 _main 中被引用c:\Users\administrator\documents\visual studio 2010\Projects\Different\Different\Different.objDifferent


错误2error LNK1120: 1 个无法解析的外部命令c:\users\administrator\documents\visual studio 2010\Projects\Different\Debug\Different.exeDifferent
什么状况啊,

[解决办法]
void __cdecl show_ploar(struct polar)
void show_polar(polar dapos)

读书人网 >C++

热点推荐