You are viewing a single comment's thread. Return to all comments →
That's an error! You returning a pointer to an object (int this case error that is destroyed after function call).
error
That's really dangerous! You need to store the string inside the class so error string must be inside the class.
class BadLengthException { public: BadLengthException(int n) { stringstream ss; ss << n; m_error = ss.str(); } const char* what() const throw() { return m_error.c_str(); } private: string m_error; };
Seems like cookies are disabled on this browser, please enable them to open this website
Inherited Code
You are viewing a single comment's thread. Return to all comments →
That's an error! You returning a pointer to an object (int this case
error
that is destroyed after function call).That's really dangerous! You need to store the string inside the class so
error
string must be inside the class.