用C++设计学生信息表?

来源:百度知道 编辑:UC知道 时间:2024/06/19 17:18:03
要求:
1.建立学生信息数据,包括:学生学号、姓名、性别和年龄
2 根据学生信息表,建立只包含姓名和年龄的学生信息简表。
3 使用继承的方法构造两具类,使用相就、应的对象数组放置各学生信息。
4 编写同名的display()成员函数,用来输出学生的信息。
5 另外编制一个函数printer(),用来根据实际对象输出它们的内容。
6 学生人数可任意变化。

#include<iostream.h>
class student //学生类
{
char name[200];
int score[3];
int q;
public:
void scan() //输入学生信息
{
cout<<"*************输入学生信息*************"<<endl;
cout<<"姓名:"<<endl;
cin>>name;
cout<<"\n"<<"成绩"<<endl;
cout<<"\n"<<"数学:"<<endl;
cin>>score[0];
cout<<"\n"<<"英语:"<<endl;
cin>>score[1];
cout<<"\n"<<"计算机:"<<endl;
cin>>score[2];
}
int jisuan() //算平均分
{
int i,p=0;
for(i=0;i<3;i++)
{
p=p+score[i];
}
q=p/3;
return q;
}
voi