String handler

envelope

  class string {
  public:
  
  string(char* s = "") { rep = new stringrep(s); }
  string(string& a) { rep = a.rep; rep->count++; } 
  string& operator=( string& a ) { 
  	   a.rep->count++;
  	   if (--rep->count <= 0 ) delete rep;
  	   rep = a.rep;
  	   return *this;
  	   }
  
  string operator+( string& a );
  
  int length() { return strlen(rep->rep); } 
  
  operator char*() { return rep->rep; }
  private:
  stringrep* rep;
  };
  

slide: A string handler class