I'm trying to create a logger function where you can pass in a message which will be logged to a text file. Sometimes I'd like to pass in a variable concatenated with my message so I could do something like:
logger("The variable is: " + variable);
The function is defined as
void logger(std::string message);
I'm using Qt, so I don't know if it's relevant but the variable will always be a QString. When I tried this it would say that no candidate function for
void logger(const QString);
So I thought why not make a second function where it would expect a concatenation:
void logger(std::string message);
void logger2(const QString message);
It compiled fine when I did
logger2("The variable is: " + variable);
However, when I debugged the passed message variable was an empty string. How do I get this to work, is it possible?
const QString&?