I am trying to change the message for bad_alloc
.
#include <iostream>
#include <iomanip>
#include <stdexcept>
using std::logic_error;
using std::bad_alloc;
class OutOfRange : public logic_error {
public:
OutOfRange(): logic_error("Bad pointer") {}
};
class OutOfMem : public bad_alloc {
public:
OutOfMem(): bad_alloc("not enough memory") {}
};
OutOfRange()
works fine, but OutOfMem
sends me an error:
No matching function for call to
std::bad_alloc::bad_alloc(const char[21])