#include <iostream>
#include <string>


struct ex1
{
    std::string reason;
    ex1(std::string reason_): reason(reason_) {};
    virtual std::string what()
    {
        return reason;
    }
};

struct ex2 : ex1
{
    std::string comment;
    ex2(std::string reason_, std::string comment_) : ex1(reason_), comment(comment_) {}
    virtual std::string what()
    {
        return reason + " " + comment;
    }
};

int main()
{
    try {
        throw ex2("Hello", "there");
    } catch (ex1 e) {
        std::cout << e.what() << '\n';
    }
    try {
        throw ex2("Hello", "there");
    } catch (ex1& e) {
        std::cout << e.what();
    }
}