Q:

try {} catch(){} c++

I have the following method:
class MyClass 
{
public:
    MyClass;

    bool method (MyClass &obj);
};

void MyClass::method (MyClass &obj)
{
    MyClass *c = new MyClass;
    try{
        //code 
        //access another method 
        return true;
    }
    catch (std::string s)
    {
    }
    return false;
}

Where should I delete the pointer  c to the object from MyClass: before return true or before return false? 

A:

What about:
void MyClass::method (MyClass &obj)
{
    MyClass c;
    try{

        //code 
        //access another method 
        return true;
    }
    catch (std::string s)
    {
    }
    return false;
}

No new -> no delete required. c is automatically destroyed when method returns. If your example is oversimplified and you need to create c with new, you should follow the other answers with the smart pointer suggestions. 

A:

You should be using some form of RAII, So you do not have to bother about deleting the object yourself.  
Using RAII, the object itself takes care of deallocating the resources acquired by it, and you do not have to do it yourself.  
One of the easiest ways of implementing RAII is using Smart pointers.
You can use unique_ptr.

A:

The simple answer is that you should use a smart pointer to manage the memory (the choice of smart pointer depends on the rest of the code), and that will simplify your code. As it is, you would have to delete it in all code paths that exit the context, which includes the two returns and potentially any other exception being thrown.

