Home > Back-end >  File input is wrong, please answer
File input is wrong, please answer

Time:09-16

#include //compile preprocessing command
#include
#include
using namespace std;//using namespace STD

//statement employees
The class Employee
{
Protected:
//to protect members
Int num.//number
String name;//name
Float basicSalary;//base pay
Float prize;//bonus
Public:
//the public function
The Employee (int nu, string na, float bs, float pr) : num (nu), name (na), basicSalary (bs), prize (pr) {}
Virtual void Show ()
{
Cout<& lt;" Number: "& lt; Cout<& lt;" Name: "& lt; Cout<& lt;" Basic salary: "& lt; Cout<& lt;" Bonus: "& lt; }
Virtual void ShowSalary ()
{
Cout<& lt;" Real salary: "& lt; }
};
Int main ()//the main function of the main ()
{
The Employee b [3]={Employee (106, "li Ming" 1, 1680, 1080), the Employee (107, "li Ming" 2, 1681, 1081), the Employee (10, "li Ming 3", 1682, 1082)};//p refer to rectangular object
Fstream f;
int x;
F.o pen (" Employee. TXT ", the ios: : out);
If (f.f ail ())
{
Cout<& lt;" Failed to open the file "& lt; exit(1);
}
for(int i=0; i<3; I++)
{
F}
f.close();
F.o pen (" Employee. TXT ", the ios: : in);
If (f.f ail ())
{
Cout<& lt;" Failed to open the file "& lt; The exit (2);
}
while(! F.e of ())
{
F> x;
Cout}
Coutf.close();
Cout & lt; <"Employee information:" & lt; for(int i=0; i<3; I++)
{//output tip
B [I] Show ();//output basic information
B [I] ShowSalary ();
}
}

CodePudding user response:

Are you going to be implemented in the employee class & lt;

CodePudding user response:

The
reference 1/f, Simple, Soft reply:
do you want to be implemented in the employee class & lt;

How to achieve?

CodePudding user response:

Operator overloading
Ostream& The operator & lt; <(ostream& OS, const Employee& TMP)
{
OsReturn the OS;
}

Cell phone tapping
  • Related