大萝卜BoBoBoBo~

导航

OJ复习2/Problem B: 平面上的点——Point类 (II)

 

 

#include <iostream>
#include <iomanip>
using namespace std;
class Point
{
private :
    double x,y;
public:
    Point(double xx = 0,double yy =  0)
    {x = xx;y = yy; cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<")"<<" is created."<<endl;}
    Point(const Point &pt){ x = pt.x; y = pt.y; cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<")"<<" is copied."<<endl;} 
    Point(int xx){x = xx; y = xx; cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<")"<<" is created."<<endl;}
    ~Point(){cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<")"<<" is erased."<<endl;}
    void show(){ cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<")"<<endl;}
};
int main()
{
    char c;
    double a, b;
    Point q;
    while(std::cin>>a>>c>>b)
    {
        Point p(a, b);
        p.show();
    }
    Point q1(q), q2(1);
    q1.show();
    q2.show();
    q.show();
}

 

posted on 2020-04-16 09:37  我有一个大萝北  阅读(219)  评论(0编辑  收藏  举报