dimanche 13 septembre 2020

Query about a given function's use in the code

i'm following this tutorial and they give us this code to test the function isLowerVowel:

#include <iostream>

bool isLowerVowel(char c, bool yIsVowel)
{
    switch (c)
    {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
        return true;
    case 'y':
        return (yIsVowel ? true : false);
    default:
        return false;
    }
}

int main()
{
    std::cout << std::boolalpha;

    std::cout << isLowerVowel('a',false) << "\n";
    std::cout << isLowerVowel('a',true) << "\n";

    std::cout << isLowerVowel('q',false) << "\n";
    std::cout << isLowerVowel('q',true) << "\n";

    std::cout << isLowerVowel('y',false) << "\n";
    std::cout << isLowerVowel('y',true) << "\n";

    return 0;
}

I dont understand what the use of yIsVowel is for, shouldnt just testing isLowerVowel be enough? Sorry i asked them but got no replies

Aucun commentaire:

Enregistrer un commentaire