title: Passing a pointer to an object in C++ & error: no matching function for call to
body: <p>I'm trying to pass a pointer to a <code>vector</code> from one free floating function to another. This all works good, however, when trying to add something to this vector I get a strange compilation error.</p>
  
  <pre><code>$ g++ PeekClientRMS.cpp
  PeekClientRMS.cpp: In function ‘void testNewWord(std::string, std::vector&lt;PeekDeque&lt;StringWrap&gt; &gt;*)’:
  PeekClientRMS.cpp:116:26: error: no matching function for call to ‘std::vector&lt;PeekDeque&lt;StringWrap&gt; &gt;::push_back(PeekDeque&lt;StringWrap&gt;*&amp;)’
    chainsp-&gt;push_back(newpd);
                            ^
  PeekClientRMS.cpp:116:26: note: candidate is:
  In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/vector:64:0,
                   from PeekClientRMS.cpp:13:
  /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/bits/stl_vector.h:901:7: note: void std::vector&lt;_Tp, _Alloc&gt;::push_back(const value_type&amp;) [with _Tp = PeekDeque&lt;StringWrap&gt;; _Alloc = std::allocator&lt;PeekDeque&lt;StringWrap&gt; &gt;; std::vector&lt;_Tp, _Alloc&gt;::value_type = PeekDeque&lt;StringWrap&gt;]
         push_back(const value_type&amp; __x)
         ^
  /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/bits/stl_vector.h:901:7: note:   no known conversion for argument 1 from ‘PeekDeque&lt;StringWrap&gt;*’ to ‘const value_type&amp; {aka const PeekDeque&lt;StringWrap&gt;&amp;}’
  </code></pre>
  
  <p>The problem seems to by introducing my custom class called <code>StringWrap</code> instead of <code>string</code>. The line of code that is causing this compilation error is <code>chainsp-&gt;push_back(newpd);</code></p>
  
  <pre><code>void testNewWord(string word, vector&lt;PeekDeque&lt;StringWrap&gt; &gt;* chainsp) {
  
      PeekDeque&lt;StringWrap&gt;* newpd = new PeekDeque&lt;StringWrap&gt;(100);
      chainsp-&gt;push_back(newpd);
  }
  
  int main(int argc, char* argv[]){   
      if(argc != 2){
          cerr &lt;&lt; "Please specify a SINGLE .txt file to process." &lt;&lt; endl;
          return(1);
      }
  
      vector&lt;PeekDeque&lt;StringWrap&gt; &gt;* chainsp = new vector&lt;PeekDeque&lt;StringWrap&gt; &gt;(); 
  
      string word;
  
      string infileName = argv[1];
      ifstream* INFILEp = new ifstream(infileName.c_str(), ios_base::in);
  
      while ((*INFILEp) &gt;&gt; word) {
          cout &lt;&lt; word &lt;&lt; endl;
          testNewWord(word, chainsp);
      }
  
      INFILEp-&gt;close();
  }
  </code></pre>
  
  <p>It's odd, because I made a simpler version of this program using <code>vector&lt;string&gt;</code> and it worked fine. I'm not really sure what this compiler error is saying and where to start debugging?</p>