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