Bon, donc j'ai finit par me rapprocher de ce que je voulais en suivant le tutorial. Je réussi donc à récuperer l'exception avec:
catch(const std::exception X)
L'ennui c'est que lorsque j'appelle la méthode what(), j'obtiens un message: "st9exception" au lieu des messages que j'attendais.
Lorsque je la récupère comme ceci:
catch(const std::exception & X)
Mon programme s'arrête instantannément.
Voici la définition de ma classe d'exception:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| class Laby_Exception : public std::exception
{
private:
std::string msg;
public:
virtual const char * what() const throw();
/* retourne un message correspondant au code
*/
Laby_Exception(const char * Msg) throw();
/* constructeur
*/
~Laby_Exception() throw();
}; |
les méthodes:
1 2 3 4 5 6 7 8 9 10 11 12 13
| Laby_Exception::Laby_Exception(const char * Msg) throw()
{
std::ostringstream oss;
oss << Msg;
this->msg = oss.str();
}
Laby_Exception::~Laby_Exception() throw() {}
const char * Laby_Exception::what() const throw()
{
return this->msg.c_str();
} |
J'ai toujours du mal à saisir le problème, si quelqu'un pouvait m'aiguiller...
Partager