I have a vector containing a struct of customer_info and a function that searches that vector for a customer name and returns an iterator to that customer. I want to be able to return A Null iterator is no matches are found ( if that is possible ) but I can't get it to work right. Here is what I have
at the part marked in red I get this errorCode:vector<Customer_Info>::const_iterator Customer_Manager::Find_Customer(string name) { int length = name.size(); string name2; bool match = false; int x = 0; char selection; for (int i = 0; i <= (length - 1); i++) name[i] = toupper(name[i]); vector <vector <Customer_Info>::iterator> temp_list; vector <vector <Customer_Info>::iterator>::iterator temp_iter; vector<Customer_Info>::iterator iter; for (iter = customer_list.begin(); iter != customer_list.end(); ++iter) { name2 = iter->name.substr(0, length); if (name == name2) { temp_list.push_back(iter); match = true; cout<<x+1 <<") " <<iter->name <<" " <<iter->address1 <<endl; x++; } } cout<<endl; if (x == 0) cout<<"No Matching Fields!" <<endl; else cout<<"Enter Selection"; cout<<"<0> to Exit "; while (true) { cin>>selection; cin.ignore(); if (selection == '0') { return iter = NULL; } if (selection > 0 && selection <= (x + 1) ) return temp_list.at(x); cout<<"Incorrect Selection" <<endl; }; }
Any Ideas as to what is wrong? Or if you can even do it like that?Code:155 C:\Dev-Cpp\Dispatch Planner\Customer_Functions.cpp no match for 'operator=' in 'iter = 0' note C:\Dev-Cpp\include\c++\3.4.2\bits\stl_iterator.h:587 candidates are: __gnu_cxx::__normal_iterator<Customer_Info*, std::vector<Customer_Info, std::allocator<Customer_Info> > >& __gnu_cxx::__normal_iterator<Customer_Info*, std::vector<Customer_Info, std::allocator<Customer_Info> > >::operator=(const __gnu_cxx::__normal_iterator<Customer_Info*, std::vector<Customer_Info, std::allocator<Customer_Info> > >&)



LinkBack URL
About LinkBacks


