热门

最新

红包

立Flag

投票

同城

我的

发布
qq_40465879
先生Douglas
4 年前
trueqq_40465879

C++中expected initializer before '.' token怎么办? 实在找不到了

完整代码

#include<iostream>
#include<math.h>
using namespace std;
class Location
{
public:
void setX(int a)
{
x=a;
}
void setY(int b)
{
y=b;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
double distance(Location &A,Location &B);
private:
int x,y;
};
double Location::distance(Location &A,Location &B)
{
double sum=sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
return sum;
cout<<"Diatance1="<<sum<<endl;
}
int main()
{
Location A,B;
void A.setX(-10);
void A.setY(-20);
void B.setX(-40);
void B.setY(60);
cout<<"A("<<A.getX()<<","<<A.getY()<<")"<<","<<"B("<<B.getX()<<","<<B.getY()<<")"<<endl;
double distance(Location A,Location B);
return 0;
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
鸭脖,爆辣的鸭脖~
立即登录