AIIQ3 - return 0; } istream& operator >>...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> #include <string> using namespace std; struct employee { string first; string last; int id; float salary; }; istream& operator >> (istream& in, employee& x); ostream& operator struct workforce { int size; employee* database; }; istream& operator >> (istream& in, workforce& w); ostream& operator void updatesalary(workforce& w, int ident, float newsalary); int main(void) { workforce w; ifstream fin("workforce.in"); ofstream fout("workforceoperators.out"); int ident; float newsalary; fin >> w; cout << "Enter the id and the new salary: "; cin >> ident >> newsalary; updatesalary(w, ident, newsalary); fout << w; system("notepad workforceoperators.out");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return 0; } istream& operator >> (istream& in, employee& x){ in>>x.first>>x.last>>x.id>>x.salary; } ostream& operator << (ostream& out, const employee& x) { out<<x.first<<endl<<x.last<<endl<<x.id<<endl<<x.salary<<endl; } istream& operator >> (istream& in, workforce& w){ int i; in>>w.size; w.database=new employee[w.size]; for(i=0;i<w.size;i++) in >>(in,w.database[i]); } ostream& operator << (ostream& out, const workforce& w){ int i; out<<w.size<<endl; for(i=0;i<w.size;i++) out<<(out,w.database[i]); } void updatesalary(workforce& w, int ident, float newsalary){ int i(0); while(1){ if(w.database[i].id==ident){ w.database[i].id=ident; w.database[i].salary=newsalary; break; } i++; } }...
View Full Document

This note was uploaded on 02/21/2010 for the course ENGM 2282 taught by Professor Phillips during the Winter '10 term at Dalhousie.

Page1 / 2

AIIQ3 - return 0; } istream& operator >>...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online