为什么当我调用这个函数时它不返回我的输入?它说它的回报支持,但它没有?

  • 本文关键字:支持 回报 调用 函数 返回 c++
  • 更新时间 :
  • 英文 :

#include <iostream>
// **Change needs_it_support so that it returns support:**
bool needs_it_support() {

bool support;

std::cout << "Hello. IT. Have you tried turning it off and on again? Enter 1 for yes, 0 for no.n";
std::cin >> support;
return support;
}
int main() {

// **Change the following line to print the function result:**
needs_it_support();  **calling function**

}

但什么都没有打印出来,我只按了1或0,我没有收到任何回复

您应该在从函数返回后打印结果,在这种情况下,您应该放这样的东西:

std::cout << needs_it_support() << std::endl;

或:

bool result  = needs_it_support();
std::cout << result << std::endl;

最新更新