I have a function in a C++ program returning a string
.
On certain conditions, e.g. if the function encounters an error or so, I want to return a special value telling the caller that something has gone wrong.
I could basically just return an empty string ""
, but the function does need the empty string as normal return value.
- How can I accomplish this?
- Do I have do create a special data structure that for my function that holds a bool if the function was successfully run and a string containing the actual return value?