You can take advantage of std:string
class LoadException: public std::exception {
private:
std::string message_;
public:
explicit LoadException(const std::string& message);
const char* what() const noexcept override {
return message_.c_str();
}
};
LoadException::LoadException(const std::string& message) : message_(message) {
}
Then the C++ scoping will take care of cleaning things up for you