URL: https://linuxfr.org/forums/programmation-c/posts/cr%C3%A9er-une-exception Title: Créer une exception Authors: Pinaraf Date: 2005年01月11日T18:21:28+01:00 Tags: Score: 0 Bonjour Je suis en train de développer une lib. Et j'aimerais créer un type XMLException (vous devinerez son utilité :) Je veux qu'il hérite de std::exception. Voici sa définition : class XMLException : public std::exception { public: XMLException(std::string message); XMLException(const char *message); XMLException(char *message); ~XMLException() {}; _const char* what () const throw();_ private: const char *msg; }; La ligne en italique semble poser problème :( Voici ce que me dit g++ : XMLException.h:34: error: looser throw specifier for `virtual XMLException::~XMLException()' /usr/include/g++/exception:56: error: overriding `virtual std::exception::~exception() throw ()' (en triple exemplaire monsieur !) voici dans XMLException.cpp la fonction : const char* XMLException::what() const throw(){ return msg; } Bref, comment ça marche ? Son message ne me semble pas très très... clair et mon bouquin sur le C++ est trop vieux pour connaître les exceptions ! Merci d'avance à quiconque pouvant m'aider !

AltStyle によって変換されたページ (->オリジナル) /