0

I am writing a program to search range of values in a vector of structs, after trying for almost a day, I am still out of luck

Here is what I am doing, I know it is wrong

{in Function}
vector::iterator it=find_if(ip_records[ip].begin(),ip_records[ip].end(), find_it("2011-01-24 20:59.20", "2011-01-24 20:59.30"));

{Defn}
struct find_it {
string start, end;
find_it(string start, string end):start(start){}
bool operator()(record const& r) const {
if ((strcmp(r.start_time.c_str(), start.c_str()) >= 0) && (strcmp(r.start_time.c_str(), end.c_str()) <= 0)){
return true;
}
}

I am not able to receive 2 string as parameters in find_it()

Here are some links from which I could not find solution
Vectors, structs and std::find
Searching c++ std vector of structs for struct with matching string
Thank you
Any help is appreciated

Community
  • 1
  • 1
rda3mon
  • 1,709
  • 4
  • 25
  • 37

1 Answers1

2

You didn't initialize the end member variable in the initialization-list:

find_it(string start, string end):start(start), end(end) {}
                                    //note this ^^^^^^^^

Now, it initializes it!

Nawaz
  • 353,942
  • 115
  • 666
  • 851