小编use*_*602的帖子

这个简单的C++函数有什么问题?

这是一个来自interiew的问题,以及下面的代码.这个功能有什么问题?

string f() {
    return "hello world";
}
Run Code Online (Sandbox Code Playgroud)

对我来说,没有任何错误,我甚至可以使用此功能运行程序:

#include <iostream>
#include <string>
using namespace std;

string f() {
    return "hello world";
}

int main() {
    string s2=f();
    cout<<s2<<endl;
}
Run Code Online (Sandbox Code Playgroud)

什么错这个功能呢?

c++ function

4
推荐指数
1
解决办法
181
查看次数

标签 统计

c++ ×1

function ×1