#include <iostream>
#include <string>
using namespace std;
class Student{
public:
Student(int n, char name[20], char s )
{ num=n; sex=s;
pName=new char[20];
strcpy(pName,name);
cout<<"构造函数被调用了"<<endl;
}
~Student( )
{ if (pName !=NULL) delete pName;
cout<<"析构函数被调用了"<<endl;
}
void Display(){cout<<num<<":"<<pName<<":"<<sex<<endl;}
private:
int num;
char *pName;
char sex;
};
void main(){
Student s1(20191212,"tom",'m');
s1.Display();
}