c++ - Boolean function -


i trying use find_if boolean function return true if:

  1. z =<10;
  2. name="john" (all lower case)

my code:

/* predicate find_if */ bool exam_pred(const exam_struct &a) {   if ((a.z=<10)&&(a.name="john"))    {      return true;   }    }  exam_struct{   int x,y;   double z;   string name; }; 

it doesn't compile when set a.name="john". question how implement a.name="john"; boolean?

you should indeed use == operator.

i wrong suggesting strcmp before, since using strings.

code:

struct exam_struct {     int x, y;     double z;     string name; };  /* predicate find_if */ bool exam_pred(const exam_struct& a) {     return a.z <= 10 && a.name=="john"; } 

note in original code not return false when check false.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -