I'm trying to create an exception class in C++ and it doesn't work. I've reduced the code to a minimum and I still can't find the error. Here is my header file :
#ifndef LISTEXCEPTION_H
#define LISTEXCEPTION_H
// C++ standard libraries
#include <exception>
/* CLASS DEFINITION */
class ListException: public exception {
};
#endif //LISTEXCEPTION_H
and here is the error I get :
error: expected class-name before ‘{’ token
This is quite unexpected. How do I solve this?
Did you mean
class ListException: public std::exception
// ^^^
?
It's subtly telling you that exception
isn't the name of a class (with a declaration that's in scope, anyway).
You probably intended std::exception
instead.
exception
lives in the std
namespace:
class ListException: public std::exception { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With