Assuming the class EMPLOYEE given below, write functions in C++ to perform following:
(i) Write the objects of EMPLOYEE to a binary file.(ii) Read the objects of EMPLOYEE from binary file and display them on screen.
![]() |
C++ File Handling Binary files - class EMPLOYEE |
Solution:
class EMPLOYEE
{
int ENO;
char ENAME[10];
public :
void GETIT()
{
cin >> ENO;
gets (ENAME);
}
void SHOWIT()
{
cout <<ENO << ENAME <<endl;
}
};
This C++ Program executes the objects of EMPLOYEE to a binary file and Read the objects of EMPLOYEE from binary file and display them on screen.
Learn More :
Program to Display%28%29
Data File Handling
- C++ Program To Count Number Of Alphabets In A File
- C++ Program To Write Numbers 1 to 100 in a data file
- C++ Initializes A String Variable And Outputs String To Disk File
- Read Content From a Text File then Count and Display the Number of Alphabets
- C++ Program to count number of blanks present in a text file
- C++ Program to count number of words in a text file
- C++ Program to Counting Words "the" in a Text File