定义一个score类,其中包含私有数据成员和公有数据成员函数,

来源:百度知道 编辑:UC知道 时间:2024/06/08 01:40:37
接上->
即num:学号,Math:数学,English:英语成绩 programming :程序设计成绩 inscore(): 输入学号和各科成绩,并且计算平均成绩 showscore(时): 输入学号和各科成绩。输入某班n(实现不能确定)个学生的学号和各科成绩,然后求各个学生的平均成绩,并列表输出学生的学号,各科成绩和平均成绩。

#include <iostream>
using namespace std;
class score
{public:
void set_score();
void show_score();
private:
 int  num;
 int  Math;
 int English;
};
int main()
{
 score s1;
 s1.set_score();
 s1.show_score();
 return 0;
}
void score::set_score()
{
 cout<<"请输入学号"<<endl;
 cin>>num;
 cout<<"请输入数学成绩"<<endl;
 cin>>Math;
 cout<<"请输入英语成绩"<<endl;
 cin>>English;
}
void score::show_score()
{
 cout<<"学号 数学成绩 英语成绩 如下"<<endl;
 cout<<num<<" "<<Math<<" "<<English<<endl;}

2 定义一个类score,求C++解答 设计一个学生类,属性:name sex address grade score (2) 试编写Java代码实现一个计数器类Counter,其中包含: 设计一个MyString类,其中包含字符数组变量(大小256 在JAVA中如何定义一个字符串,包含如下内容 1、定义学生成绩类Score,其私有数据成员有学号、姓名、物理、数学、外语、平均成绩。 定义一个Document类,包含成员变量name,从Document派生出Book类,增加PageCount变量。编写主函数 定义一个学生类Student,类中包含3个数据成员:name(姓名),sex(性别),score1(成绩1), 定义一个Employee类,其中包括姓名、街道地址、城市和邮编等属性 类的定义中包含自己的对象,有何用?