Bonjour
En ce moment, je programme une librairie. Elle ne peux donc utiliser std::cerr pour afficher les erreurs, et j'aimerais faire comme j'ai l'habitude en python : déclencher des exceptions.
J'ai essayé ceci, mais ça ne marche pas :
La fonction :
bool rename_file(std::string source, std::string destination) {
std::ifstream flux_in;
std::ofstream flux_out;
std::string ligne;
//fpkg_exception the_exception;
if (!is_file(source)) {
throw "File not found";
return false;
}
return true;
}
C'est volontairement réduit, bien sûr...
Maintenant, j'essaye de l'utiliser :
try (…)
Forum Programmation.c++ Déclencher et capturer une exception
25
oct.
2004