//"pointer4.h"
class Point{
private:
int X,Y;
public:
Point(int xx=0,int yy=0){X=xx;Y=yy;counterp++;}
Point(Point &p);
int GetX(){return X;}
int GetY() {return Y;}
static int counterp;
static void Getc(){cout<<"object id="<<counterp<<endl;}
};
int Point::counterp=0;
Point::Point(Point &p)
{
X=p.X;
Y=p.Y;
counterp++;
}
#include<iostream.h>//通过指针访问类的静态成员函数
#include"pointer4.h"
void main()
{
void (*gc)()=Point::Getc;//声明一个指向函数的指针,指向类的静态成员函数
//指向函数的指针的形式为 数据类型 (*指针名)(形参表)
Point A(4,5);
cout<<"Point A,"<<A.GetX()<<","<<A.GetY();
gc();//输出对象序列号,直接通过指针访问静态成员函数
Point B(A);
cout<<"Point B,"<<B.GetX()<<","<<B.GetY();
gc();
}