problème avec une exception
Salut je désire écrire ma propre classe not_opened en redéfinissant la méthode what mais ça coince lors de la compilation.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| class not_opened:public exception
{
public:
string what()
{
return ("fichier n'a pas été ouvert !");
}
};
int main()
{
try{
not_opened e;
throw e;
}
catch ( const not_opened e)
{
e.what();
}
return 0;
} |
ça m'affiche l'erreur suivante :
Code:
passing `const not_opened' as `this' argument of `std::string not_opened::what()' discards qualifiers
Que faire ?
Merci .