Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "Employee.h"
- using namespace std;
- istream& Employee::operator >>(std::istream &is, Employee &s)
- {
- cout<<"Enter surname : ";
- is>>s.surname;
- cout<<"Enter given name : ";
- is>>s.given;
- int flag1=0,flag2=0;
- do
- {
- cout<<"Enter number : ";
- is>>s.number;
- if (is.fail())
- {
- cout<<"Try again\n";
- is.clear();
- is.ignore(2000,'\n');
- }
- else if (s.number<0)
- {
- cout<<"Enter a positive value\n";
- is.ignore(2000,'\n');
- }
- else if (char(is.get())!='\n')
- {
- cout<<"Try again\n";
- is.ignore(2000,'\n');
- }
- else flag1=1;
- }
- while (flag1==0);
- do
- {
- cout<<"Enter pay rate : ";
- is>>s.payrate;
- if (is.fail())
- {
- cout<<"Try again\n";
- is.clear();
- is.ignore(2000,'\n');
- }
- else if (s.payrate<0)
- {
- cout<<"Enter a positive value\n";
- is.ignore(2000,'\n');
- }
- else if (char(is.get())!='\n')
- {
- cout<<"Try again\n";
- is.ignore(2000,'\n');
- }
- else flag2=1;
- }
- while (flag2==0);
- return is;
- }
- ostream& Employee::operator <<(std::ostream &os, Employee &s)
- {
- os<<s.number<<" "<<s.payrate<<" "<<s.surname<<", "<<s.given<<endl;
- return os;
- }
- EmployeeList::EmployeeList(int maxn)
- {
- Maxn=maxn>0?maxn:50;
- n=0;
- list=new Employee[Maxn];
- }
- EmployeeList::~EmployeeList()
- {
- if (list!=NULL)
- delete [] list;
- }
- void EmployeeList::display() const
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement