CodeBlocks编译C++项目出错
error: ld returned 1 exit status。
Fun.h
#include<iostream>
using namespace std;
#include<math.h>
class Point{
private:
int x,y;
public:
void set_xy(int a,int b);
int getx();
int gety();
};
float line_long(Point m,Point n);
Fun.cpp
#include "Fun.h"
void Point::set_xy(int a,int b)
{
x=a;y=b;
}
int Point::getx()
{
return x;
}
int Point::gety()
{
return y;
}
float line_long(Point m,Point n)
{
return sqrt((pow((m.getx()-n.getx()),2)) + pow((m.gety()-n.gety()),2));
}
main.cpp
#include "Fun.h"
int main()
{
Point p1,p2;
p1.set_xy(0,0);
p2.set_xy(1,1);
cout<<line_long(p1,p2);
}
解决错误
在同一个项目中先后建立了以上三个文件,语法无错误,编译出现如题错误提示,接下来,我们要设置链接及编译。
右击项目目录中的文件选择属性,做如下所示设置
重新编译
正常运行