#include
  #include

  class string {
      struct srep {
          char* s;           // указатель на данные
          int   n;           // счетчик ссылок
  };
      srep *p;

  public:
      string(char *);        // string x = "abc"
      string();              // string x;
      string(string &);      // string x = string ...
      string& operator=(char *);
      string& operator=(string &);
      ~string();
      char& operator[](int i);

      friend ostream& operator<<(ostream&, string&); friend istream& operator>>(istream&, string&);

      friend int operator==(string& x, char* s)
          {return strcmp(x.p->s, s) == 0; }

      friend int operator==(string& x, string& y)
          {return strcmp(x.p->s, y.p->s) == 0; }

      friend int operator!=(string& x, char* s)
          {return strcmp(x.p->s, s) != 0; }

      friend int operator!=(string& x, string& y)
          {return strcmp(x.p->s, y.p->s) != 0; }

  };