Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #ifndef ENTRY_H
  2. #define ENTRY_H
  3. #include <iostream>
  4. #include <stdexcept>
  5. #include <limits>
  6.  
  7.  
  8. class entry
  9. {
  10.     public:
  11.         entry (const std::string& in_val) { val = in_val; cnt = 0; }
  12.  
  13.         std::string operator*() const { return val; }
  14.  
  15.         operator int() const { return cnt; }
  16.  
  17.         int operator++ (int) { return cnt++; }
  18.  
  19.         bool operator< (const entry& et) { return (val < et.val); }
  20.  
  21.         friend std::ostream& operator <<(std::ostream& os, const entry& et) { os << "[" << et.val << " " << et.cnt << "]"; return os; }
  22.  
  23.         friend std::istream& operator >>(std::istream& is, entry& et)
  24.         {
  25.             char //musi czytać nawias
  26.             is >> //nawias
  27.             if (/*nawias*/ != '[')
  28.                 throw std::invalid_argument();
  29.             is >> et.val >> et.cnt;
  30.             is >> parenthesis;
  31.             if (/*nawias*/ != ']')
  32.                 throw std::invalid_argument();
  33.  
  34.             return is;
  35.         }
  36.  
  37.     private:
  38.         std::string val;
  39.         int cnt;
  40. };
  41.  
  42. #endif // ENTRY_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement