title: What is the way to inherit std::string right?
body: <p>Recently, I have been wanting to define a subclass spstring of std::string. It declared in spstr.h:</p>
  
  <pre><code>#include &lt;cctype&gt;
  #include &lt;string&gt;
  #include &lt;algorithm&gt;
  #include &lt;sstream&gt;
  #include &lt;stdint.h&gt;
  #include &lt;xstring&gt;
  
  
  class spstring : public std::string {
  public:
      spstring(std::string s):std::string(s){}  //Declare the constructor
      int stoi(); //Declare stoi
      spstring Spstring(std::string s); ////Declare mandatory conversion function
  };
  
  spstring spstring::Spstring(std::string s)
  {
      spstring spstr(s); 
      return(spstr);
  }
  </code></pre>
  
  <p>However, when tested in main.cpp:</p>
  
  <pre><code>spstring byteaddstr(std::string(argv[4])); //convertchar* to spstring
  int byteadd;
  byteadd=byteaddstr.stoi(); //call byteaddstr.stoi
  </code></pre>
  
  <p>it failed to be complied for:</p>
  
  <blockquote>
    <p>error C2228: left of “.stoi” must have class/struct/union</p>
  </blockquote>
  
  <p>Sounds strange, since byteaddstr indeed an instance of spstring, why cannot call its member function?</p>