#include<iostream> #include<fstream> using namespace std; class employeefile { private: char employee[20]; char worktype[20]; int age; public: void getdata(void) { cout << "Enter employee name:"; cin >>employee; cout << "Enter work type:"; cin >> worktype; cout << "Enter age:"; cin >> age; } void showdata(void) { cout << "\n employee name:"<<employee<<endl; cout << "\n work type:" << worktype << endl; cout << "\n age:" << age << endl; } }; int main() { employeefile E; E.getdata(); ofstream creatfile("employee.txt", ios::binary); creatfile.write((char*)&E, sizeof(E)); creatfile.close(); ifstream infine("employee.txt", ios::binary); infine.read((char*)&E, sizeof(E)); E.showdata(); infine.close(); }