AIVQ1 - w.add_employee(e w.write(fout fout.close system"notepad workforce.out" return 0 void employee:read(istream& in in>>

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; const int N = 100; class employee { public: void read(istream& in); void write(ostream& out); private: string first; string last; int id; float salary; }; class workforce { public: workforce(string l, string n); void add_employee(const employee& e); void write(ostream& out); private: string location; string name; int size; employee list[N]; }; int main(void) { ifstream fin("workforces.in"); ofstream fout("workforce.out"); employee e; string loc, nam; fin >> loc >> nam; workforce w(loc, nam); while(1) { e.read(fin); if(fin.eof()) break;
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: w.add_employee(e); } w.write(fout); fout.close(); system("notepad workforce.out"); return 0; } void employee::read(istream& in) { in >> first >> last >> id >> salary; } void employee::write(ostream& out) { out << first << " " << last << " " << id << " " << salary << endl; } workforce::workforce(string l, string n){ location=l; name=n; size=0; } void workforce::add_employee(const employee& e){ list[size]=e; size++; } void workforce::write(ostream& out){ int i; out<<location<<endl<<name<<endl; for(i=0;i<size;i++) list[i].write(out); }...
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

AIVQ1 - w.add_employee(e w.write(fout fout.close system"notepad workforce.out" return 0 void employee:read(istream& in in>>

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