Boolean function example (C++ programming tutorial)

39
22



Check out for more free engineering tutorials and math lessons!
C++ Programming Tutorial: Boolean function example.

Please support my work:
PATREON |
Every dollar is seriously appreciated and enables me to continue making more tutorials

Nguồn:https://dothihoa.com/

39 COMMENTS

  1. This video helped me out a lot thank you. Working on a school project right now and needed a refresher on bool type functions. I am wondering though, is pin.length a predefined function? I'm not sure how the compiler knows whether to make the bool value true or false just based off of "pin.length". Thanks for your help 🙂

  2. Could you explain why this code returns false if one value is true:
    bool lookFor(string valueOne, string valueTwo)

    {

    bool trueFalse{};

    int trueOccurances{};

    int falseOccurances{};

    for (int i = 0; i < memberNamesLength; i++)

    {

    if (valueOne == memeberNames[i] || valueTwo == memeberNames[i])

    {

    santFalskt = true;

    trueOccurances++;

    }

    else

    {

    santFalskt = false;

    falseOccurances++;

    }

    }

    cout << 'n' << "lookFor, true: " << trueOccurances << 'n';

    cout << 'n' << "lookFor, false: " << falseOccurances << 'n';

    return trueFalse;

    }

  3. wouldn't a four letter string also return true since the function is only looking at the length of the string not whether it's digits or letters?

  4. I don't know why visual studio has problems reading pin.length as it says that it must have class type. I tried putting in a class box above specifying length but it still gave no result. Would be appreciated thanks 🙂

  5. If a person would enter letters as a pin, your program would still work, which shouldnt since pins are only numbers. So it was a bad idea to use string for this

  6. how can the string pass for int data???? I think that the sring is passed to the true statement but I don't understand why there is on declaration for integers is it because int is declared at main

LEAVE A REPLY

Please enter your comment!
Please enter your name here