student.cpp
来自「一次作业练习」· C++ 代码 · 共 56 行
CPP
56 行
#include "Student.h"
//Constructing an empty Student-object
Student::Student()
{
}
//Constructing an student-object with name=n, student_id=id
Student::Student(string n, int id)
{
set_name(n);
set_id(id);
}
//get the student's name
string Student::get_name()
{
return name;
}
//get the student's id
int Student::get_id()
{
return student_id;
}
//set n as the student's name
void Student::set_name(string n)
{
name=n;
}
//set id as the student's id
void Student::set_id(int id)
{
student_id=id;
}
//pre: fin contains at least one line with a name and a student-id
//post: has read and stored the name and student-id
void Student::read(istream& fin)
{
string n;
int id;
fin>>n>>id;
set_name(n);
set_id(id);
}
//written a line containing the name and the student_id
void Student::write(ostream& fout)
{
fout<<get_name()<<setw(10)<<get_id();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?