Advertisement
KShah

Untitled

Nov 12th, 2021
687
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // вывод из потока
  2.     friend std::ostream& operator<<(std::ostream& os, const String& s) {
  3.         for (size_t i = 0; i < s.length(); ++i){
  4.             os << s[i];
  5.         }
  6.         return os;      
  7.     }
  8.     // ввод в поток
  9.     friend std::istream& operator>>(std::istream& in, String& s) {
  10.         s.clear();
  11.         char c;
  12.         while (in.get(c)) {
  13.             if (c == '\n') {
  14.                 break;
  15.             }
  16.             s.push_back(c);
  17.         }
  18.         return in;
  19.     }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement