Understanding bool functions in product comparison?

  • Thread starter Thread starter torquerotates
  • Start date Start date
  • Tags Tags
    Confused Functions
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
torquerotates
Messages
207
Reaction score
0

Homework Statement



I'm given the member function:

bool Product::is_better_than(Product b) const
{
if(price==0) return true;
if (b.price price==0) return false;
return score/price>b.score/b.price;
}

I'm really confused about the last line "return score/price>b.score/b.price;". Does it mean, return true if ">" holds and return false if "<" doesn't hold?
 
Physics news on Phys.org
Yes. You can think of all comparisons as functions that return true or false depending on whether the condition is satisfied.
 
oh I see. Thanks