c++:error C2601: 'main' : local function definitions are illegal

#include<iostream>#include<cmath>usingnamespacestd;classPoint{private:doubleX,Y;publi... #include<iostream>
#include<cmath>
using namespace std;
class Point{
private:
double X,Y;
public:
Point(double x,double y){X=x;Y=y;}
friend double GetLength(Point A,Point B);
double GetX(){return X;}
double GetY(){return Y;}
};
double GetLength(Point A,Point B)
{ return sqrt(abs(A.GetX()-B.GetX())*abs(A.GetX()-B.GetX())+abs(A.GetY()-B.GetY())*abs(A.GetY()-B.GetY()));
int main()
{ Point A(5,6);
Point B(1,7);
cout<<GetLength(A,B)<<endl;
return 0;
}
------------------------------------------------
D:\studying in college\C++\Point friend.cpp(16) : error C2601: 'main' : local function definitions are illegal
D:\studying in college\C++\Point friend.cpp(21) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
展开
 我来答
百度网友c730f2621
2010-05-23 · TA获得超过220个赞
知道答主
回答量:96
采纳率:0%
帮助的人:87.3万
展开全部
double GetLength(Point A,Point B)
{ return sqrt(abs(A.GetX()-B.GetX())*abs(A.GetX()-B.GetX())+abs(A.GetY()-B.GetY())*abs(A.GetY()-B.GetY()));
你这句话后面少了个 } ,加上去就不会出面你说的情况了
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式