#include
#include
using namespace std;
class student{
public:
static int count;
student(){++count;}
student(string ID="",string name="",int sex=0,int grade=0):
m_ID(ID),m_name(name),m_sex(sex),m_grade(grade){++count;}
~student(){--count;}
void getData(){
cout< if(m_sex==1) cout<<"男";
if(m_sex==2) cout<<"女";
cout<<' '< }
void setData(string ID="",string name="",int sex=0,
int grade=0){
if(ID!="") m_ID=ID;
if(name!="") m_name=name;
if(sex!=0) m_sex=sex;
if(grade!=0) m_grade=grade;
}
void showCount(){
cout<<"计数值:"< }
friend void showData(student& stu);
private:
string m_ID;
string m_name;
int m_sex;
int m_grade;
};
void showData(student& stu){
cout< if(stu.m_sex==1) cout<<"男";
if(stu.m_sex==2) cout<<"女";
cout<<' '<}
int student::count=0;
int main(){
student stu1("001","张三",1,4);
stu1.getData();
cout<<"修改学生信息"< stu1.setData("002");
stu1.getData();
stu1.showCount();
cout<<"新建堆中的对象"< student* stu2=new student("003","李四",2,5);
stu2->getData();
stu2->showCount();
delete stu2;
cout<<"删除了一条"< stu1.showCount();
cout<<"调用友元函数"< showData(stu1);
}