设计评选优秀教师和学生的程序,当输入一系列教师或学生的记录后,将优秀学生及教师的姓名列出来.
基类BASE:
Char name[8];//姓名
含纯虚函数 isgood()
类student;
如果考试成绩超过90分,则调用函数isgood()返回TURE
类teacher;
如果一年发表的论文超过了3篇,则调用函数isgood()返回true.
要尽量紧凑的程序,我就做不出来.对了,请加上注释,让我学习学习,虽然是临时抱佛脚....

解决方案 »

  1.   

    virtual void IsGood(void) = 0;
      

  2.   

    You must be a rich kid, able to waste money and time in school. But eventually, you will be punished by real society.class Person
    {
    public:
        char name[8];
        virtual bool IsGood() = 0;
    };class Student: public Person
    {
    public:
        int m_score;    virtual bool IsGood() { return m_score > 90; }
    }class Teacher: public Person
    {
    public:
        int m_publishedpaper;    virtual bool IsGood() { return m_publishedpaper > 3; }
    }
      

  3.   

    谢谢.不过VOID MAIN()那里的调用没有写吗?
      

  4.   

    完全看不懂你写什么......如何把你的程序在MAIN里调用?
      

  5.   

    You must be a rich kid, able to waste money and time in school. But eventually, you will be punished by real society---->(呵呵,updownfind 看不懂[袁锋]写的这些东东啊!)
      

  6.   

    不要要求别人帮你写程序
    这个问题候捷的《深入浅出MFC》上清清楚楚
      

  7.   

    You must be a rich kid, able to waste money and time in school. But eventually, you will be punished by real society.class Person
    {
    public:
        char name[8];
        virtual bool IsGood() = 0;
    };class Student: public Person
    {
    public:
        int m_score;    virtual bool IsGood() { return m_score > 90; }
    }class Teacher: public Person
    {
    public:
        int m_publishedpaper;    virtual bool IsGood() { return m_publishedpaper > 3; }
    }
    ////////////////////////翻译////////////////////////
    你这个在学校虚度光阴和金钱的家伙,将来在现实社会中一定会吃苦头的
    /////////////////////////////////////////////////////
    程序说明
    这位袁峰大哥帮你写了一个基类Person和二个子类Student,Teacher,你在程序中可以这样
    #include "stdafx.h"
    #include "iostream.h"
    class Person
    {
    public:
        char name[8];
        virtual bool IsGood() = 0;
    };class Student: public Person
    {
    public:
        int m_score;    virtual bool IsGood() { return m_score > 90; }
    }class Teacher: public Person
    {
    public:
        int m_publishedpaper;    virtual bool IsGood() { return m_publishedpaper > 3; }
    }int main()
    {         //定义个如上的数组,像下面相类似的
             Persor abc[10];
            //然后想法往数组里写入什么关于学生老师姓名和分数之类的东西,然后把它显示到屏幕上,就OK了
             
    return 0;
    }
      

  8.   

    还有那个"Persor abc[10];"错了,应该是"Person abc[10];",见笑见笑