Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4. #include<iterator>
  5.  
  6. class worker
  7. {
  8. private:
  9. std::string _name;
  10. int _age;
  11. double _pay;
  12. public:
  13. worker() : _age{0}, _pay{0.0} {}
  14. worker(std::istream& entry){ input(entry); }
  15.  
  16. std::istream& input(std::istream& x){ return x >> _name >> _age >> _pay ; }
  17.  
  18. const std::string& get_name() { return _name; }
  19. const int& get_age(){ return _age; }
  20. const double& get_pay(){ return _pay;}
  21. };
  22.  
  23. class vecworkers
  24. {
  25. private:
  26. std::vector<worker> vec_workers;
  27. public:
  28. void input(std::istream& x)
  29. {
  30. worker temp;
  31. while(temp.worker::input(x))
  32. vec_workers.push_back(temp);
  33.  
  34. }
  35.  
  36. void output(std::ostream& x)
  37. {
  38. worker temp;
  39. for( std::vector<worker>::const_iterator it = vec_workers.begin() ; it != vec_workers.end() ; ++it )
  40. {
  41. temp = *it ;
  42. std::cout << temp.get_name() << " "<< temp.get_age() << " " << temp.get_pay() << std::endl;
  43. }
  44. }
  45.  
  46. };
  47.  
  48. int main()
  49. {
  50. vecworkers w1;
  51. w1.input(std::cin);
  52. w1.output(std::cout);
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement