title: no viable constructor copying array element of type 'MyString'
body: <p>I was supposed to get a output like this:</p>
  
  <pre><code>    1. abcd-efgh-abcd-
  
      2. abcd-
  
      3.
  
      4. abcd-efgh-
  
      5. efgh-
  
      6. c
  
      7. abcd-
  
      8. ijAl-
  
      9. ijAl-mnop
  
      10. qrst-abcd-
  
      11. abcd-qrst-abcd- uvw xyz
  
      about
  
      big
  
      me
  
      take
  
      abcd
  
      qrst-abcd-
  </code></pre>
  
  <p>So I wrote this...</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  // ------------------MY CODE HERE-----------------
  class MyString : public string {
  public:
      MyString():string(){}
      MyString(const string &amp;s):string(s){}
      MyString(const char *c):string(c){}
      MyString(MyString &amp;ms):string(ms){} 
      string operator()(int start_, int length_){
          return this-&gt;substr(start_, length_);
      }
  };
  // -----------------------------------------------
  int CompareString( const void * e1, const void * e2) {
      MyString * s1 = (MyString * ) e1;
      MyString * s2 = (MyString * ) e2;
      if( *s1 &lt; *s2 )     return -1;
      else if( *s1 == *s2 ) return 0;
      else if( *s1 &gt; *s2 ) return 1;
  }
  int main() {
      MyString s1("abcd-"),s2,s3("efgh-"),s4(s1);
      MyString SArray[4] = {"big","me","about","take"};
      cout &lt;&lt; "1. " &lt;&lt; s1 &lt;&lt; s2 &lt;&lt; s3&lt;&lt; s4&lt;&lt; endl;
      s4 = s3;    s3 = s1 + s3;
      cout &lt;&lt; "2. " &lt;&lt; s1 &lt;&lt; endl;
      cout &lt;&lt; "3. " &lt;&lt; s2 &lt;&lt; endl;
      cout &lt;&lt; "4. " &lt;&lt; s3 &lt;&lt; endl;
      cout &lt;&lt; "5. " &lt;&lt; s4 &lt;&lt; endl;
      cout &lt;&lt; "6. " &lt;&lt; s1[2] &lt;&lt; endl;
      s2 = s1;    s1 = "ijkl-";
      s1[2] = 'A' ;
      cout &lt;&lt; "7. " &lt;&lt; s2 &lt;&lt; endl;
      cout &lt;&lt; "8. " &lt;&lt; s1 &lt;&lt; endl;
      s1 += "mnop";
      cout &lt;&lt; "9. " &lt;&lt; s1 &lt;&lt; endl;
      s4 = "qrst-" + s2;
      cout &lt;&lt; "10. " &lt;&lt; s4 &lt;&lt; endl;
      s1 = s2 + s4 + " uvw " + "xyz";
      cout &lt;&lt; "11. " &lt;&lt; s1 &lt;&lt; endl;
      qsort(SArray,4,sizeof(MyString), CompareString);
      for( int i = 0;i &lt; 4;++i )
          cout &lt;&lt; SArray[i] &lt;&lt; endl;
      //use string substr(int start,int length); 
      cout &lt;&lt; s1(0,4) &lt;&lt; endl;
      //use string substr(int start,int length); 
      cout &lt;&lt; s1(5,10) &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>I referenced to several exemplary code, all of which suggested this should work. Yet it turned out that when I tried to g++ this source code, error occurred...</p>
  
  <pre><code>maGicZ:PA3 MagicZ$ g++ part_1.cpp 
  part_1.cpp:23:1: warning: control may reach end of non-void function [-Wreturn-type]
  }
  ^
  part_1.cpp:26:27: error: no viable constructor copying array element of type 'MyString'
      MyString SArray[4] = {"big","me","about","take"};
                            ^~~~~
  part_1.cpp:11:2: note: candidate constructor not viable: expects an l-value for 1st argument
          MyString(MyString &amp;ms):string(ms){};    
          ^
  part_1.cpp:26:33: error: no viable constructor copying array element of type 'MyString'
      MyString SArray[4] = {"big","me","about","take"};
                                  ^~~~
  part_1.cpp:11:2: note: candidate constructor not viable: expects an l-value for 1st argument
          MyString(MyString &amp;ms):string(ms){};    
          ^
  part_1.cpp:26:38: error: no viable constructor copying array element of type 'MyString'
      MyString SArray[4] = {"big","me","about","take"};
                                       ^~~~~~~
  part_1.cpp:11:2: note: candidate constructor not viable: expects an l-value for 1st argument
          MyString(MyString &amp;ms):string(ms){};    
          ^
  part_1.cpp:26:46: error: no viable constructor copying array element of type 'MyString'
      MyString SArray[4] = {"big","me","about","take"};
                                               ^~~~~~
  part_1.cpp:11:2: note: candidate constructor not viable: expects an l-value for 1st argument
          MyString(MyString &amp;ms):string(ms){};    
          ^
  1 warning and 4 errors generated.
  </code></pre>
  
  <p>Tried to figure out this for the whole night, but in vain. </p>
  
  <p>Thanks in advance.</p>