📄 07_08.cpp
字号:
// 07_08.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <conio.h>
#include <iostream.h>
class student
{
char id[64]; // 学号
char name[64]; // 姓名
int age; // 年龄
char department[64]; // 系
friend ostream& operator << (ostream& out, student& stu);
friend istream& operator >> (istream& in, student& stu);
};
ostream& operator << (ostream& out, student& stu)
{
out << "id = " << stu.id << endl;
out << "name = " << stu.name << endl;
out << "age = " << stu.age << endl;
out << "department = " << stu.department << endl;
out << endl;
return out;
}
istream& operator >> (istream& in, student& stu) {
in >> stu.id >> stu.name >> stu.age >> stu.department;
return in;
}
int main(int argc, char* argv[])
{
student stu1, stu2;
cout << "please input id, name, age, department of student 1: " << endl;
cin >> stu1;
cout << "please input id, name, age, department of student 2: " << endl;
cin >> stu2;
cout << endl;
cout << "the information of student 1: " << endl;
cout << stu1;
cout << endl << "the information of student 2: " << endl;
cout << stu2;
getch();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -