Passing a pointer to an object in C++ & error: no matching function for call to -


i'm trying pass pointer vector 1 free floating function another. works good, however, when trying add vector strange compilation error.

$ g++ peekclientrms.cpp peekclientrms.cpp: in function ‘void testnewword(std::string, std::vector<peekdeque<stringwrap> >*)’: peekclientrms.cpp:116:26: error: no matching function call ‘std::vector<peekdeque<stringwrap> >::push_back(peekdeque<stringwrap>*&)’   chainsp->push_back(newpd);                           ^ peekclientrms.cpp:116:26: note: candidate is: in file included /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/vector:64:0,                  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<_tp, _alloc>::push_back(const value_type&) [with _tp = peekdeque<stringwrap>; _alloc = std::allocator<peekdeque<stringwrap> >; std::vector<_tp, _alloc>::value_type = peekdeque<stringwrap>]        push_back(const value_type& __x)        ^ /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/bits/stl_vector.h:901:7: note:   no known conversion argument 1 ‘peekdeque<stringwrap>*’ ‘const value_type& {aka const peekdeque<stringwrap>&}’ 

the problem seems introducing custom class called stringwrap instead of string. line of code causing compilation error chainsp->push_back(newpd);

void testnewword(string word, vector<peekdeque<stringwrap> >* chainsp) {      peekdeque<stringwrap>* newpd = new peekdeque<stringwrap>(100);     chainsp->push_back(newpd); }  int main(int argc, char* argv[]){        if(argc != 2){         cerr << "please specify single .txt file process." << endl;         return(1);     }      vector<peekdeque<stringwrap> >* chainsp = new vector<peekdeque<stringwrap> >();       string word;      string infilename = argv[1];     ifstream* infilep = new ifstream(infilename.c_str(), ios_base::in);      while ((*infilep) >> word) {         cout << word << endl;         testnewword(word, chainsp);     }      infilep->close(); } 

it's odd, because made simpler version of program using vector<string> , worked fine. i'm not sure compiler error saying , start debugging?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -