* All rightsreserved.
* 文件名称:Student.cpp
* 作 者:王立强
* 完成日期:2013 年 03 月19 日
* 版本号: v1.0
* 输入描述:略
* 问题描述:略
* 输出:略
*/
#include <iostream>
using namespace std;
class Student
{
public:
void set_data(int n, char *p,char s);
void display( );
private:
num=7;
char name[20];
char sex;
};
void Student::set_data(int n, char *p,char s)
{ num=n;
strcpy(name,p);
sex=s;
}
void Student::display( )
{ cout<<"num: "<<num<<endl;
cout<<"name: " <<name<<endl;
cout<<"sex: " <<sex<<endl;
}
int main()
{ Student stud1,stud2;
stud1.set_data(1,"He",'f');
stud2.set_data(2,"She",'m');
stud1.display();
stud2.display();
return 0;
}