I have following code:
我有如下代码:
#include <iostream>
bool function(int a, int b, int &foo) {
std::cout << "I have been called and I";
if (a > b)// some magic that maybe changes 'foo'
{
foo++;
std::cout << " did change the variable" << std::endl;
return true;//inform that i have changed the value
}
std::cout << " did NOT change the variable" << std::endl;
return false;
};
int main()
{
bool changed = false;
int bar = 0;
for (size_t i = 0; i < 10; i++)
{
changed = changed || function(i,4,bar);
}
std::cout << "Bar:" << bar;
std::cin.get();
std::cin.get();
return 0;
}
#include <io