怎么错了?请大家指教
class person{
private:
char Name[20];
int Age;
int sex;
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(Name,name);
Age=age;
Sex=(sex=='m'?0:1);
}
char *person::GetName ()
{return Name;}
int person::GetAge ()
{return Age;}
char person::GetSex ()
{return (Sex==0?'m':'f');}
void person::ShowMe ()
{cout<<GetName()<<'\t'<<GetAge()<<'\t'<<GetSex()<<endl;}
#include <iostream.h>
#include <string.h>
#include "person.h"
void main()
{
char name[20],sex;
int age;
person person1,person2;
cout<<"Enter a person's name,ageandsex:";
cin>>name>>age>>sex;
person1.Register(name,age,sex);
cout<<"person1:\t";
person1.ShowMe ();
person1.Register ("zhangsan",19,'m');
cout<<"person1:\t";
person1.ShowMe ();
person2=person1;
cout<<"person2:\t";
person2.ShowMe ();
}
错误:
Sex' : undeclared identifier
'cout' : undeclared identifier
'<<' illegal, right operand has type 'char *'
'endl' : undeclared identifier