求一个人事资料输入输出的程序
大家帮我看下下面的程序,因为我是自学C++的类,所以很多不懂的东西,下面的程序运行老是有错误,还麻烦帮我解释下各个部分的详细的含义,谢谢了~#include<iostream.h>
#include<string.h>
class Person
{private:
char m_strName[20];
int m_nAge;
int m_nSex;
public:
void Register(char *name, int age, char sex);
char* GetName();
int GetAge();
char GetSex();
void ShowMe();
}
void Person::Register(char *name, int age, char sex)
{strcpy(m_strName, name);
m_nAge=age;
m_nSex=(sex=='m'?0:1);
}
char *Person::GetName()
{return m_strName;}
int Person::GetAge()
{return m_nAge;}
char Person::GetSex()
{return (m_nSex==0?'m':'f');}
void Person::ShowMe()
{cout<<GetName()<<'\t'<<GetAge()<<'\t'<<GetSex()<<endl;}
void main()
{char name[20], sex;
int age;
Person person1, person2;
cout<<"Enter a person's name, age, sex:";
cin>>name>>age>>sex;
person1.Register(name, age, sex);
cout<<"person1:\t";
person1.ShowMe();
person1.Register("Zhang3","19",'m');
cout<<"person1:\t";
person1.ShowMe();
person2=person1;
cout<<"person2:\t";
person2.ShowMe();
}