//Ex6_9.cpp
#include "iostream" 
#include "cstring" 
using namespace std;
class Person
{private:
   char name[20];
   char sex;
   int age; 
   static int num;   //声明num为静态数据成员
 public:
   void display()
	{cout<<name<<":"<<sex<<","<<age<<endl;}
   void set(char *n,char s,int a)
	{strcpy(name,n);
     sex=s;
     age=a;
	 num++;}
   int getnum()
	{return(num);}
};
int Person::num=0;   //静态数据成员初始化 	
void main()
{Person p,*p1;
 p.set("WangHong",'m',20);   //调用类的成员函数
 p.display();
 p1=new Person;    //通过new运算符动态创建Person对象
 p1->set("HuGe",'m',18); 
 p1->display();
 cout<<"Number of Object is:"<<p.getnum()<<endl; 
}
