daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include "Employee.h"
  3. using namespace std;
  4. istream& Employee::operator >>(std::istream &is, Employee &s)
  5. {
  6.     cout<<"Enter surname : ";
  7.     is>>s.surname;
  8.     cout<<"Enter given name : ";
  9.     is>>s.given;
  10.     int flag1=0,flag2=0;
  11.     do
  12.     {
  13.         cout<<"Enter number : ";
  14.         is>>s.number;
  15.         if (is.fail())
  16.         {
  17.             cout<<"Try again\n";
  18.             is.clear();
  19.             is.ignore(2000,'\n');
  20.         }
  21.         else if (s.number<0)
  22.         {
  23.             cout<<"Enter a positive value\n";
  24.             is.ignore(2000,'\n');
  25.         }
  26.         else if (char(is.get())!='\n')
  27.         {
  28.             cout<<"Try again\n";
  29.             is.ignore(2000,'\n');
  30.         }
  31.         else flag1=1;
  32.     }
  33.     while (flag1==0);
  34.     do
  35.     {
  36.         cout<<"Enter pay rate : ";
  37.         is>>s.payrate;
  38.         if (is.fail())
  39.         {
  40.             cout<<"Try again\n";
  41.             is.clear();
  42.             is.ignore(2000,'\n');
  43.         }
  44.         else if (s.payrate<0)
  45.         {
  46.             cout<<"Enter a positive value\n";
  47.             is.ignore(2000,'\n');
  48.         }
  49.         else if (char(is.get())!='\n')
  50.         {
  51.             cout<<"Try again\n";
  52.             is.ignore(2000,'\n');
  53.         }
  54.         else flag2=1;
  55.     }
  56.     while (flag2==0);
  57.     return is;
  58. }
  59. ostream& Employee::operator <<(std::ostream &os, Employee &s)
  60. {
  61.     os<<s.number<<"  "<<s.payrate<<"  "<<s.surname<<", "<<s.given<<endl;
  62.     return os;
  63. }
  64. EmployeeList::EmployeeList(int maxn)
  65. {
  66.     Maxn=maxn>0?maxn:50;
  67.     n=0;
  68.     list=new Employee[Maxn];
  69. }
  70. EmployeeList::~EmployeeList()
  71. {
  72.     if (list!=NULL)
  73.         delete [] list;
  74. }
  75. void EmployeeList::display() const
  76. {
  77.  
  78. }
RAW Paste Data
Top