//writing into a file
Employee *newEmpPtr=new Employee;
char data[100];int num;
ofstream fout("emp.txt",ios::app);
cout<<"enter the number of records to be entered";
cin>>num;
for(int i=0;i<num;i++)
{
if (!fout.good())
{
cout<<"File not found"<<endl;
exit(1);
}
fout<<newEmpPtr->getName();
fout<<newEmpPtr->getAge();
fout<<newEmpPtr->getDob();
fout<<newEmpPtr->getSkill();
fout<<newEmpPtr->getDesignation();
fout<<newEmpPtr->getAddress();
fout<<data<<endl;
}
cout << endl;
}
and the Employee.h is
#ifndef _EMPLOYEE_H
#define _EMPLOYEE_H
#include<iostream>
#include<fstream>
class Employee
{
private:
string name;
int age;
int dob;
string skill;
string designation;
string address;
public:
Employee();
void setField(string,int,int,string,string,string);
void displayEmployee();
static int numEmployee;
string getName();
int getAge();
int getDob();
string getSkill();
string getDesignation();
string getAddress();