Reputation: 805
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?
Upvotes: 6
Views: 1996
Reputation: 227370
exception
lives in the std
namespace:
class ListException: public std::exception { ... }
Upvotes: 3
Reputation: 490018
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.
Upvotes: 4
Reputation: 258548
Did you mean
class ListException: public std::exception
// ^^^
?
Upvotes: 10