Bonjour,
Pourquoi faut il absolument qu'une exception puisse être copié ?
Par exemple, le code suivant ne compile pas car le compilateur ne trouve pas le constructeur par recopie :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #include <iostream> #include <sstream> #include <exception> #include <limits> using namespace std; class MyException : public runtime_error { public : MyException( const char * what ) throw() : runtime_error( what ) {} private : MyException( const MyException & what ) throw(); const MyException & operator=( const MyException & what ) throw(); }; int main() { try { throw( MyException( "because" ) ); } catch( const exception & e ) { cout << "main : " << e.what() << endl; } cout << "Appuyez sur entrée pour continuer..."; cin.ignore( numeric_limits<streamsize>::max(), '\n' ); return 0; }
Partager