Home:ALL Converter>Exception in exception constructor

Exception in exception constructor

Ask Time:2017-02-25T23:55:28         Author:Mauro H. Leggieri

Json Formatter

Assume this piece of C++ code:

class myexception1
{
public:
    myexception1()
    {};
};

class myexception2
{
public:
    myexception2()
    {
        throw myexception1();
    };
};

void test()
{
    try
    {
        throw myexception2();
    }
    catch (...)
    {
    }
};

If I run the test function, which kind of exception will receive the catch block? Could this generate some memory leak because throwing an exception from an exception constructor?

Author:Mauro H. Leggieri,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/42458185/exception-in-exception-constructor
yy