I\'m having a problem with optional function parameter in C++
What I\'m trying to do is to write function with optional parameter which is passed by reference, so th
This is how I solved this question:
My original function didn't have a returned error string: bool MyClass::validateXML(const QString& fileName, const QUri& schemaUri);
I wanted to add the results of the validation in an error string so I implemented: bool MyClass::validateXML(const QString& fileName, const QUri& schemaUri, QString& errorString = *(std::make_unique().get()));
This way, you can reference the errorString in validateXML without checking if it's valid, and no memory leaks.