Pass temporary object to function that takes pointer

前端 未结 4 1726
星月不相逢
星月不相逢 2020-12-18 01:27

I tried following code :

#include 
#include
using namespace std;

string f1(string s)
{
   return s=\"f1 called\";
}

void f2(s         


        
4条回答
  •  甜味超标
    2020-12-18 01:48

    Your program doesn't compile because f1 has a parameter and you're not passing any.

    Additionally, the value returned from a function is an rvalue, you can't take its address.

提交回复
热议问题