⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentee.cpp

📁 一次作业练习
💻 CPP
字号:
#include "StudentEE.h"

//constructing an empty StudentEE-object
StudentEE::StudentEE()
{

}

//post: has constructed an student-object with name = n, student_id = id, course3 = 0, course4 = 0
StudentEE::StudentEE(string n, int id)
:Student(n,id){
 set_course3(0);
 set_course4(0);
}

//pre: fin contains at least one line with a name and a 
//     student-id, and the credit points of course3 and 
//     course4
//post: has read and stored the name and student-id and
//      the credit points of course3 and course4
void StudentEE::read(istream& fin)
{
  int c3,c4;
  Student::read(fin);//use read function of class Student to read and store the name and student-id of student
  fin>>c3>>c4; //read and store the course 3 and course 4
  set_course3(c3);
  set_course4(c4);
}

//post: has written a line containing the name, student_id and 
//      course1 and course 2
void StudentEE::write(ostream& fout)
{
 fout<<"EE       ";
 Student::write(fout); //use write function of class Student
 fout<<setw(10)<<get_course3()<<setw(10)<<get_course4()<<endl; //output the value of course 3 and course 4
}

//set i as the course3's value
void StudentEE::set_course3(int i)
{
 course3=i;
}

//set i as the course4's value
void StudentEE::set_course4(int i)
{
 course4=i;
}

//get course3's value
int StudentEE::get_course3()
{
 return course3;
}

//get course4's value
int StudentEE::get_course4()
{
 return course4;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -