求助:error C2550: 'Ponit' : constructor initializer lists are only allowed on cons
程序代码:
//类定义 class Point { public: Point(int x=0,int y=0):x(x),y(y) {} Ponit(const Point &p); ~Point() {count--;} int getx() const {return x;} int gety() const {return y;} static void showcount(); private: int x,y; static int count; }; //类实现 #include"Point.h" #include<iostream> using namespace std; int Point::count=0; Point::Ponit(const Point &p):x(p.x),y(p.y) { count++; } void Point::showcount() { cout<<"Objiect count="<<count<<endl; } //主函数 #include"Point.h" #include<iostream> using namespace std; int main() { Point a(4,5); cout<<"Point A:"<<a.getx()<<","<<a.gety(); Point::showcount(); Point b(a); cout<<"Point B:"<<b.getx()<<","<<b.gety(); Point::showcount(); return 0; }