📄 studentcs.cpp
字号:
#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<<setw(10)<<get_course1()<<setw(10)<<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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -