阅读背景:

如果输出不重要,则不会调用函数

来源:互联网 

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



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: