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

📄 student.cpp

📁 一次作业练习
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -