标题:刚学C++,怎么那么多错误呢
取消只看楼主
梁朝斌
Rank: 4
等 级:业余侠客
帖 子:192
专家分:288
注 册:2012-10-21
结帖率:100%
 问题点数:0 回复次数:0 
刚学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();
}
        

搜索更多相关主题的帖子: void include person public return 
2013-04-24 21:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-405413-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059350 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved