title: Return value for a << operator function of a custom string class in C++
body: <p>I am trying to create my own std::string wrapper to extend its functionality.
  But I got a problem when declaring the &lt;&lt; operator.
  Here's my code so far:</p>
  
  <p>my custom string class:</p>
  
  <pre>class MyCustomString : private std::string
  {
  public:
    std::string data;
    MyCustomString() { data.assign(""); }
    MyCustomString(char *value) { data.assign(value); }
    void Assign(char *value) { data.assign(value); }
    // ...other useful functions
    std::string & operator &lt;&lt; (const MyCustomString &src) { return this->data; }
  };</pre>
  
  <p>the main program:</p>
  
  <pre>int main()
  {
    MyCustomString mystring("Hello");
    std::cout &lt;&lt; mystring; // error C2243: 'type cast' : conversion from 'MyCustomString *' to 'const std::basic_string&lt;_Elem,_Traits,_Ax&gt; &' exists, but is inaccessible
  
    return 0;
  }</pre>
  
  <p>I wanted cout to treat the class as a std::string, so that I won't need to do something like:</p>
  
  <pre>std::cout &lt;&lt; mystring.data;</pre>
  
  <p>Any kind of help would be appreciated!</p>
  
  <p>Thanks.</p>
  
  <p>Just fyi: my IDE is Microsoft Visual C++ 2008 Express Edition.</p>