Sign in to follow this  

Exception Object Scope

Recommended Posts

In the following code, what scope does the MyException object belong to. Does it go out of scope when the catch block is complete, the application exits or will this leak memory?
class MyException
    std::string _message;
    std::string Message() { return _message; }

    MyException(std::string error)
        _message = error;

void SomeFunction();

void main()
    catch(MyException e)

void SomeFunction()
    throw MyException("My error Message");

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this