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;
}