刚学C++,怎么那么多错误呢
#include <iostream.h>#include <string.h>
class person
{
protected:
char name[10];
int sex;
int age;
public:
Person(char *na,int ag,char se)
{
strcpy(name, na);
sex= se;
age = ag;
}
void initname(char *na)
{
strcpy(name, na);
}
void initsex(int se)
{
sex=se;
}
void initage(int ag)
{
age=ag;
}
char * getname()
{
return name;
}
int getage()
{
return age;
}
int getsex()
{
return sex;
}
void printf()
{
cout<<"姓名:"<<name<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"年龄:"<<age<<endl;
}
};
class teacher:public person
{
char post;
char salary;
public:
teacher(char *na,int ge,int se,char *po,char *sa):person(na,ag,se)
{
strcpy(post,po);
salary(salary,sa);
}
void printf()
{
person::printf();
cout<<"职位:"<<post<<endl;
cout<<"工资:"<<salary<<endl;
}
};
class student:public person
{
char xuehao[10];
char Class[10];
public:
student(char *na,int ag,int se,char *xh,char *cl):person(na,ag,se)
{
strcoy(xuehao,xh);
strcpy(Class,cl);
}
printf()
{
person::printf();
cout<<"学号:"<<xuehao<<endl;
cout<<"班级:"<<Class<<ensl;
}
};
void main()
{
teacher te("梁朝斌",22,男,"大学","5000");
student st("梁朝斌",22,男,"20112111225","11B");
te.printf();
cout<<"__________________"<<endl;
st.printf();
}