So I have this 2 nested custom exception class in one of my classes and what I was trying to do is to throw the exception by calling its constructors and initialize _msg and then catch the _msg with what(). But I couldn't compile my codes.
class GradeTooHighException : public std::exception {
public:
GradeTooHighException(void);
virtual const char* what(void) const throw();
private:
std::string _msg;
};
class GradeTooLowException : public std::exception {
public:
GradeTooLowException(void);
GradeTooLowException(const Bureaucrat &bur);
virtual const char* what(void) const throw();
private:
std::string _msg;
};
The error:
c++ -Wall -Werror -Wextra -Wshadow -std=c++98 -pedantic -MMD -c -o main.o main.cpp
In file included from main.cpp:13:
In file included from ./Bureaucrat.hpp:16:
./Form.hpp:35:9: error: exception specification of overriding function is more lax than base version
class GradeTooHighException : public std::exception {
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/exception:101:13: note: overridden virtual function is here
virtual ~exception() _NOEXCEPT;
^
In file included from main.cpp:13:
In file included from ./Bureaucrat.hpp:16:
./Form.hpp:44:9: error: exception specification of overriding function is more lax than base version
class GradeTooLowException : public std::exception {
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/exception:101:13: note: overridden virtual function is here
virtual ~exception() _NOEXCEPT;
^
2 errors generated.
make: *** [main.o] Error 1
Thanks for any help in advance.