为什么无法调用构造函数?代码应该怎样修改?

图片说明
/*5、编写C++程序,实现如下功能:
a.定义一个类,Point, 具有x, y轴坐标两个私有数据成员(float类型);
b.具有获取和设置x,y值的公有函数;写出两种构造函数;其原型为:
Point();//此时初始化x,y为0
Point(float xx,float yy);
c.具有计算与另一个类对象p1之间距离的公有函数:float calculate_distance(Point p1);
d. 在主函数中,提示输入p1, p2两点的x,y坐标,并计算两点的距离;
e.在main函数中测试你所设计的所有成员函数。*/

#include <iostream>
#include <math.h>
using namespace std; 

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class Point{
    public:
        Point(){
            x=0;
            y=0;
        }                  //无参数的构造函数 
        Point(float xx,float yy);  //有参数的构造函数 
        float calculate_distance(Point p1);
    private:
        float x,y;
};
Point::Point(float xx,float yy){
            x=xx;
            y=yy;
            cout<<"("<<x<<","<<y<<")"<<endl;
}
float Point::calculate_distance(Point p1){
            return (float)sqrt((x-p1.x)*(x-p1.x)+(y-p1.y)*(y-p1.y));

}
int main(int argc, char** argv) {
    Point p,p1;     //定义对象p、p1 
    float x,y;      //对象p的私有数据成员 
    float x1,y1;    //对象p1的私有对象成员
    float d1=0,d2=0;
    cin>>x>>y;
    cin>>x1>>y1;
    Point p;         //调用无参数的构造函数 
    Point p(x,y);    //调用有参数的构造函数 
    p1.Point(x1,y1);
    d1=p.calculate_distance(p1);
    d2=p1.calculate_distance(p);
    cout<<"两点间距离为"<<d1<<endl;
    cout<<"两点间距离为"<<d2<<endl;
    return 0;
}

34行已经有Point p, p1;了
40行又有Point p;
导致重复定义。
41行又定义了Point p(x, y);
可以改名:
40行
Point p2;
41行
Point p3(x,y);
下面调用相应修改

#include <iostream>
#include <math.h>
using namespace std; 

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class Point{
    public:
        Point(){
            x=0;
            y=0;
        }                  //无参数的构造函数 
        Point(float xx,float yy);  //有参数的构造函数 
        float calculate_distance(Point p1);
    private:
        float x,y;
};
Point::Point(float xx,float yy){
            x=xx;
            y=yy;
            cout<<"("<<x<<","<<y<<")"<<endl;
}
float Point::calculate_distance(Point p1){
            return (float)sqrt((x-p1.x)*(x-p1.x)+(y-p1.y)*(y-p1.y));

}
int main(int argc, char** argv) {
    Point p,p1;     //定义对象p、p1 
    float x,y;      //对象p的私有数据成员 
    float x1,y1;    //对象p1的私有对象成员
    float d1=0,d2=0;
    cin>>x>>y;
    cin>>x1>>y1;
    Point p2;         //调用无参数的构造函数 
    Point p3(x,y);    //调用有参数的构造函数 
    p1 = Point(x1,y1);
    d1=p.calculate_distance(p1);
    d2=p1.calculate_distance(p);
    cout<<"两点间距离为"<<d1<<endl;
    cout<<"两点间距离为"<<d2<<endl;
    return 0;
}

报错很明显了,说你变量重定义了,你40行定义了一个变量p,41行又定义一个p,肯定不行啊

point p;是声明了一个point变量,重复声明