假设我有两个函数和一个变量,
在这些函数中,都会涉及到变量
为什么两个函数都没有被调用,如何确保两个函数被调用并增加“number”的值,而不考虑返回值?
int number;
bool foo (void);
bool footoo (void);
在这些函数中,都会涉及到变量
number
的一些逻辑操作,例如:number++;
return(rand()%2);
然后我这样调用它们:
if (foo() && footoo())
{
cout << "Two foo true!"
}
为什么两个函数都没有被调用,如何确保两个函数被调用并增加“number”的值,而不考虑返回值?
bool b1 = foo(); bool b2 = footoo(); if (b1 && b2 ) { /* ... */ }
- jrokif (foo() + footoo() == 2) cout << "Two foo true!";
- Pete Becker