1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Confused about bool functions

  1. Feb 27, 2010 #1
    1. The problem statement, all variables and given/known data

    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?
     
  2. jcsd
  3. Feb 27, 2010 #2

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    Yes. You can think of all comparisons as functions that return true or false depending on whether the condition is satisfied.
     
  4. Feb 27, 2010 #3
    oh I see. Thanks
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Confused about bool functions
  1. Confusion about scanf (Replies: 1)

Loading...