I have a function that takes const string& value as argument. I am trying to get the value of this string so that I can manipulate it in the function. So I want to store the value into a string returnVal but this does not work:
string returnVal = *value
Simply do
string returnVal = value;
Since value is not a pointer but a reference you do not need the pointer-dereferencing-operator (otherwise it would be const string *value).
string returnVal = value;
value isn't a pointer that needs dereferencing, it's a reference and the syntax is the same as if you're dealing with a plain old value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With