在主函数测试Point p1(1,1)和Point p2(p1),分别打印坐标值

写一类Point,私有变量 int x,int y, 公有函数 无参构造函数和带参构造函数 复制构造函数和 void show()普通函数,在main函数测试Point p1(1,1)和Point p2(p1),并打印p1和p2的坐标值。

定义拷贝构造函数就行了

class Point
{
    private:
        int x,y;
    public:
        Point() {}
        Point(int px,int py) {x=px;y=py;}
        Point(Point &pt) {x = pt.x;y=pt.y;}
        void show() {cout<<x<<","<<y<<endl;}
};

void main()
{
    Point p1(1,1);
    Point p2(p1);
    p1.show();
    p2.show();
}