Function takes a ref to a string but not a string literal from the call

May 7, 2018 at 9:28am
Hello there folks!

I have a problem with some code. My function would be like:

1
2
3
void function(const std::string& string1){
//do something here
}


The thing is that I cannot call the function like

 
function("SomeTextHere");


but If I declare a string above that line and use that in the function it just works. Is this because of the declaration of the literal as a char*?

Thank you for any replies!
May 7, 2018 at 10:16am
I don't see why this wouldn't work. What error message do you get?
May 7, 2018 at 12:30pm
Just tested your code. It works. If you are having trouble, it is probably not from that function.
Topic archived. No new replies allowed.