早上好,尝试编写以下代码,以便它可能返回“ Hello,World!”。
#include "iostream"
#include"string"
using std::string;
using namespace std;
std::string hello()
{
return "Hello, World!";
}
int main ()
{
hello ();
return 0; }
让代码编译器运行时出现0个错误,也不会警告并运行,然后运行库结果,如所附图片所示。因此任何人都可以找出丢失的内容,从而返回所需的结果!谢谢running the code
您的函数hello()
返回字符串“ Hello,world!”。但是,从main
调用该函数后,您将不会对返回的值进行任何操作。
您需要输出一些东西!试试这个小的修改:
int main ()
{
cout << hello() << endl;
return 0;
}
似乎您没有在处理该函数的返回值。