title: pass string& to class method C++
body: <p>Trying to call my StringUtil class to access  createTrimmedString method passing the string reference, string&amp;.</p>
  <pre><code>--- error: cannot call member function ‘void StringUtil::createTrimmedString(const string&amp;)’ without object
         vehicleRegA = StringUtil::createTrimmedString(vinLine.substr(vehicleDataLen+201,60));
                                                                                           ^
  joinNcfClu.cpp:151:81: error: cannot call member function ‘void StringUtil::createTrimmedString(const string&amp;)’ without object
         vehicleRegB = StringUtil::createTrimmedString(vinLine.substr(vehicleDataLen+261,8));
                                                                                            ^
  </code></pre>
  <pre><code>#include &lt;iostream&gt;
  #include &quot;Inventory.h&quot;
  #include &lt;time.h&gt;
  #include &quot;StringUtil.h&quot;
  
  void Inventory::getVehicleResults(ifstream * inFile, stringList&amp; vehicleList,
                                 string typeOfVehicle, stringList&amp; miscList, string&amp; vinLine)
  {
      int features_max;
      int t_Len;
      int vehicleDataLen;
  
    //StringUtil S;
      string prevSeqNum;
      if ( typeOfVehicle == &quot;A&quot; )
      {
              features_max = 14;
              Len = 36;
              vehicleDataLen = features_max * t_Len;
              if ( vehicleList.size() == 0 )
              {
                      claSeqNum = vinLine.substr(vehicleDataLen,7);
     
                      vehicleRegA = StringUtil::createTrimmedString(vinLine.substr(vehicleDataLen+57,70));
                      vehicleRegB = StringUtil::createTrimmedString(vinLine.substr(vehicleDataLen+261,8));
         
                      vehicleKey = vinLine.substr(vehicleDataLen+269,9);
                      actual_veh = vinLine.substr(vehicleDataLen+289,16);
              }
          }
          else
          {
             // 
          }
  
  }
  
  //StringUtil.h
  
  #include &lt;string&gt;
  using namespace std;
  #include &lt;list&gt;
  
  typedef list&lt;string &gt; vehicleList;
  
  class StringUtil
  {
  
  public:
  
     StringUtil()
     {
  
     };
  
     ~StringUtil();
  
     void createTrimmedString(const std::string&amp; vinLine);
      
  private:
  }
  
  
  };
  </code></pre>