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

猜你喜欢

转载自www.cnblogs.com/Begin-Again/p/12710571.html
今日推荐