#include "Teacher.h" #include #include #include #include #include using namespace std; void printTeacher(Teacher teacher[],int size) { for (int i = 0; i < size; i++) { teacher[i].print(); } } int main() { Teacher ts[4]; fstream fs; fs.open("Teacher.bin", ios::out | ios::binary); for (int i = 0; i < 4; i++) { string a; int b; double c; cin >> a >> b >> c; ts[i] = Teacher(a, b, c); fs.write(reinterpret_cast(&ts[i]), sizeof(Teacher)); } fs.close(); fs.open("Teacher.bin", ios::in | ios::binary); for (int i = 0; i < 4; i++) { fs.read(reinterpret_cast(&ts[i]), sizeof(Teacher)); } fs.close(); printTeacher(ts, 4); }