list<string> cannot pass it to an class in c++ -


i have list datas list<string> l; , if pass value class process gives me error

process p; p.getnames(l);  

and have header file process.h

 class process {     public:         void getnames(list<string> ll);      }; 

and have cpp file process.cpp

void getnames(list<string> ll) { // can use names here } 

error

undefined reference `process::getname(std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >)' 

the error you're getting linker error because you've defined free function named getname rather member function getname. fix this, change .cpp file have

process::getname(list<string> names) 

and should good. error compiler thinks you're defining random function no connection process, when compiles code , tries use process::getname linker can't find implementation it, , it's not smart enough know free function defined intended member function, hence poor diagnostic.


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -