return a||b ; return a&&b; return a,b,c?

时间:2022-10-05 17:01:57

return a||b的意思就是如果a是true则返回a,否则返回b
return a&&b的意思就是如果a是true就则返回b,否则返回a
return a,b,c的意思就是返回c

#include <bits/stdc++.h>
using namespace std;
bool test1()
{
    bool a = true;
    bool b = false;
    return a||b;
}
bool test2()
{
    bool a = true;
    bool b = false;
    return a&&b;
}
int test3() 
{
    int a = 1;
    int b = 2;
    int c = 3;
    return a,b,c;
}
int main()
{
    cout << test1() << endl;//true->1
    cout << test2() << endl;//false->0
    cout << test3() << endl;//3
    return 0;
}