Reputation: 223
I'm creating a customized exception class
class my_error: public std::exception
{
public:
//! Constructs parse error
my_error(const char* param_msg, std::string param_reason) throw()
{
msg = param_msg;
reason = param_reason;
}
~my_error() throw() {}
private:
string msg;
string reason
};
and throw it with this way
throw my_error("something wrong", "coffee is too hot");
and catch with
catch(ems_error& ex) {
// do somehitng here
}
question: should i call delete on this ex variable? currently my program works fine without delete but I'm worry abbout memory leak
Upvotes: 1
Views: 94
Reputation: 119164
Exception objects are automatically destroyed after being handled. (See C++11 §15.1/4)
Upvotes: 5