#include
using namespace std;
class Point
{
double x,y;
static int m;
public:
Point(double a=0,double b=0):x(a),y(b)
{
m++;
}
~Point()
{
m--;
}
void show()
{
cout<<"the number of Point is "<<m<<endl;
}
};
int Point::m=0;
int main()
{
Point p1;
Point *p=new Point(1,2);
p->show();
delete p;
p1.show();
return 0;
}
想问一下,题里面的x,y,a,b有什么用啊?
c++的成员初始化列表, 为x,y赋值,相当于 x=a;y=b;