注册 登录
编程论坛 新人交流区

build为什么老报错啊,请达人指点!

shamer 发布于 2007-10-06 13:16, 477 次点击

//point.h头文件
#include"iostream"
#include"cmath"
using namespace std;
class point
{
private:
double x,y;
public:
point(double =0,double =0);
double Getx();
double Gety();
void Setxy(double,double);
~point();
};
const int num=10;
void Set(point *);
void Display(point *);
double Lenth(point *);

//*************************************
// main 主函数实现
//*************************************
#include"point.h"
point::point(double a,double b)
{x=a;y=b;}
double point::Getx() {return x;}
double point::Gety() {return y;}
void point::Setxy(double a,double b)
{
x=a;y=b;
}
point::~point()
{
cout<<"delete it:"<<x<<","<<y<<endl;
}
int main()
{
point *p=new point[];
if(p==NULL)
{
cout<<"地址申请失败"<<endl;
return 0;
}
Set(p);
// cout<<"内存块的数据如下:"<<endl;
// Display(p);
cout<<"组成的折线长度为:"<<endl;
cout<<Lenth(p);
delete []p;
return 0;
}
//****************************************
//Set(p)函数的实现
//****************************************
point *set(point *p)
{
int i;
double a,b;
for(i=0;i<10;i++,p++)
{
cin>>a>>b;
p->Setxy(a,b);
}
p=p-i+1;
return p;
}
//****************************************
//Display函数的实现
//****************************************
/*void Display(point *p)
{
for(int i=0;i<num;i++)
{
cout<<(p+i)->Getx()<<","<<(p+i)->Gety<<endl;
}
}*/
//*****************************************
//Lenth函数的实现
//*****************************************
double Lenth(point *p)
{
double sum(0.0),a1,a2,b1,b2;
a1=p->Getx();
a2=p->Gety();
for(int i=1;i<10;i++)
{
a2=(p+i)->Getx();
b2=(p+i)->Gety();
sum=sum+sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2));
a1=a2;
b1=b2;
}
return sum;
}

5 回复
#2
枫叶情缘2007-10-06 13:24
看不明白
#3
shamer2007-10-06 13:44
回复:(shamer)build为什么老报错啊,请达人指点!
就是编译一下 然后看build的报错我就是发现不了错误 很郁闷呢
#4
nuciewth2007-10-06 13:49
报什么错,我在别人的电脑上没有编译器.
把错误报出来.
#5
nuciewth2007-10-06 13:50
double sum(0.0)这个是赋值?
#6
shamer2007-10-06 19:55
回复:(nuciewth)double sum(0.0)这个是赋值?

--------------------Configuration: point - Win32 Debug--------------------
Linking...
point.obj : error LNK2001: unresolved external symbol "void __cdecl Set(class point *)" (?Set@@YAXPAVpoint@@@Z)
Debug/point.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

point.exe - 1 error(s), 0 warning(s)

1