?????

what do you mean by
fout.write((char *)&sal, sizeof(sal));

what did "sal" role right after class Salary? What does the above code do?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 ofstream fout;
 class Salary
{
float basic,gross,deduction,da,hra,ot,oth,pf,lic,fadv,coops,hdfc,netpay;
int abdys;
public:
void add();
}sal;

void Salary::add()
{employee::add();
cout<<"\n\n\tBasic Pay: ";
cin>>basic;
cout<<"\n\n\tDays Absent: ";
cin>>abdys;
cout<<"\n\n\tOvertime Hours: ";
cin>>oth;
cout<<"\n\n\tLoans and Savings\n";
cout<<"\n\n\tLIC: ";
cin>>lic;
cout<<"\n\n\tHDFC: ";
cin>>hdfc;
cout<<"\n\n\tCo Operative Society: ";
cin>>coops;
calculate();
fout.write((char *)&sal,sizeof(sal));
fout.close();
}
what do you mean by
fout.write((char *)&sal, sizeof(sal));

It writes the sal global to the fout output stream, in binary mode.

http://www.cplusplus.com/reference/ostream/ostream/write/
Topic archived. No new replies allowed.