仅供参考,共同进步。

百思不得己

#include<iostream>
#include<iomanip>
using namespace std;
class Point
{
private :
        double x, y;
        static int  m , n;
public :
    Point(double a=0)
    {
        x=a;y=a;
        m++;n++;
    }
    Point(double a,double b)
    {
        x=a; y=b;
        m++;n++;
    }
    Point(const Point&p)
    {
        x=p.x; y=p.y;
        m++;n++;
    }
    ~Point()
    {
        m--;
    }
    int show()
    {
        std::cout<<"Point : ("<<setprecision(16)<<x<<", "<<setprecision(16)<< y<<")"<<std::endl;
    }
    static void showCounter(){cout<<"Current : "<<m<<" points."<<endl;}
    static void showSumOfPoint(){cout<<"In total : "<<n<<" points."<<endl;}

};
int Point::   m=0;
int Point::   n=0;
void showPoint(Point &p){p.show();}
void showPoint(Point &q,Point &w,Point &e){q.show();w.show();e.show();}


int main()
{
    char c;
    double a, b;
    Point q;
    while(std::cin>>a>>c>>b)
    {
        Point p(a, b);
        p.show();
        p.showCounter();
    }
    q.showSumOfPoint();
    Point q1(q), q2(1);
    Point::showCounter();
    showPoint(q1, q2, q);
    Point::showSumOfPoint();
}

  

posted @ 2018-03-15 17:52  南山i  阅读(132)  评论(0编辑  收藏  举报