HRusev

03.Company.h

May 24th, 2023
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | Source Code | 0 0
  1. #ifndef COMPANY_H
  2. #define COMPANY_H
  3.  
  4. #include <string>
  5. #include <istream>
  6.  
  7. class Company {
  8.     std::string name;
  9.     int id;
  10. public:
  11.     std::string getName() const {
  12.         return this->name;
  13.     }
  14.  
  15.     int getId() const {
  16.         return this->id;
  17.     }
  18.  
  19.     friend std::istream& operator>>(std::istream& stream, Company& company);
  20. };
  21.  
  22. std::istream& operator>>(std::istream& stream, Company& company) {
  23.     return stream >> company.name >> company.id;
  24. }
  25.  
  26. std::ostream& operator<<(std::ostream& stream, const Company& company) {
  27.     return stream << company.getName() << " " << company.getId();
  28. }
  29.  
  30. #endif // !COMPANY_H
Advertisement
Add Comment
Please, Sign In to add comment