studentcs.~cp
来自「一次作业练习」· ~CP 代码 · 共 65 行
~CP
65 行
#include "StudentCS.h"
//Constructing an empty StudentCS-object
StudentCS::StudentCS()
{
}
//has constructed an student-object with name = n,
// student_id = id, course1 = 0, course2 = 0
StudentCS::StudentCS(string n, int id)
: Student(n,id){
set_course1(0);
set_course2(0);
}
//pre: fin contains at least one line with a name and a
// student-id, and the credit points of course1 and
// course2
//post: has read and stored the name and student-id and
// the credit points of course1 and course2
void StudentCS::read(istream& fin)
{
int c1,c2;
Student::read(fin);
fin>>c1>>c2;
set_course1(c1);
set_course2(c2);
}
//post: has written a line containing the name, student_id and
// course1 and course 2
void StudentCS::write(ostream& fout)
{
fout<<"CS ";
Student::write(fout);
fout<<" "<<get_course1()<<" "<<get_course2()<<endl;
}
//set i as the value of course1
void StudentCS::set_course1(int i)
{
course1=i;
}
//set i as the value of course2
void StudentCS::set_course2(int i)
{
course2=i;
}
//get course1's value
int StudentCS::get_course1()
{
return course1;
}
//get course2's value
int StudentCS::get_course2()
{
return course2;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?