vendredi 3 septembre 2021

exception specification of overriding function is more lax than base version compile with g++ [duplicate]

Here is my code:

class InvalidInstruction : public exception{
string mess;
public:
InvalidInstruction(string instruction)
{
    mess = "Invalid: " + instruction;
}
const char *what() const throw()
{
    return mess.c_str();
} };

when i compile the above code, i get the message:

./error.h:50:7: error: exception specification of overriding function is more lax than base version.

class Redeclared : public exception /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:103:13: note: overridden virtual function is here virtual ~exception() _NOEXCEPT;

Can you guide me to fix this error?. Thanks!

Aucun commentaire:

Enregistrer un commentaire