From http://zhedahht.blog.163.com/blog/static/25411174201171214133316/
Problem ( ) : What is the printed result of C + + code in operation ?
BOOL Fun1 (char* str)
{
printf ("%s\n", str);
return false;
}
BOOL Fun2 (char* str)
{
printf ("%s\n", str);
return true;
}
int _tmain (int argc, _tchar* argv[])
{
bool res1, res2;
res1 = (Fun1 ("a") && Fun2 ("B")) | | (Fun1 ("C") | | Fun2 ("D"));
Res2 = (Fun1 ("a") && Fun2 ("B")) && (Fun1 ("C") | | Fun2 ("D"));
return res1 | | res2;
}
Answer : Print out 4 lines, respectively a, C, D, a.
return is False, no matter Func2 (" B ") ,fun1 (" a ") && Func2 (" B ") The result of span lang= "ZH-CN" is False
when calculating Rest2 , first Func1 ("a") prints a line of content. Because Func1 ("a") returns false, as before, Func2 ("B") omits the calculation. Because the result of FUN1 ("a") && Func2 ("B") is false, regardless of the result of FUN1 ("C") && Func2 ("D"), the result of the entire expression is false , so Fun1 ("C") && Func2 ("D") are ignored.
C + + Problem-20140924