title: How does std::string overload the assignment operator?
body: <pre><code>class mystring { 
  private:
   string s;
  public:
   mystring(string ss) { 
    cout &lt;&lt; "mystring : mystring() : " + s &lt;&lt;endl; 
    s = ss;
   }
   /*! mystring&amp; operator=(const string ss) { 
    cout &lt;&lt; "mystring : mystring&amp; operator=(string) : " + s &lt;&lt;endl;
    s = ss; 
    //! return this; 
    return (mystring&amp;)this; // why COMPILE ERROR
   } */
   mystring operator=(const string ss) {
    cout &lt;&lt; "mystring : mystring operator=(string) : " + s &lt;&lt;endl;
    s = ss;
    return *this;
   } 
   mystring operator=(const char ss[]) {
    cout &lt;&lt; "mystring : mystring operator=(char[]) : " &lt;&lt; ss &lt;&lt;endl;
    s = ss;
    return *this;
   }
  };
  
  mystring str1 =  "abc"; // why COMPILE ERROR
  mystring *str2 = new mystring("bcd");
  </code></pre>
  
  <p>So the questiones are</p>
  
  <ol>
  <li><p>how to make a correct mystring&amp; opeartor= overload?That is,how could I return a reference rather than a pointer?(could we tranfer between reference and pointer in C++?)</p></li>
  <li><p>how to make a correct mystring operator= overload?I thought the source code would work fine,but it turns out I still could not assign const char[] to mystring as if I didn't overload the operator=.</p></li>
  </ol>
  
  <p>thanks.</p>