cpp:exception_inheritance
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cpp:exception_inheritance [2020/05/04 12:04] – gthanos | cpp:exception_inheritance [2023/05/15 14:08] (current) – gthanos | ||
---|---|---|---|
Line 55: | Line 55: | ||
} | } | ||
} catch(BaseException ex) { | } catch(BaseException ex) { | ||
- | cout << ex.what(); | + | cout << ex.message(); |
} catch(DerivedException ex) { | } catch(DerivedException ex) { | ||
- | cout << ex.what(); | + | cout << ex.message(); |
} | } | ||
return 0; | return 0; | ||
Line 85: | Line 85: | ||
</ | </ | ||
- | Παρατηρήστε ότι ενώ στην 2η περίπτωση παράγεται ένα // | + | Παρατηρήστε ότι ενώ στην 2η περίπτωση παράγεται ένα // |
Η απάντηση στο παραπάνω ερώτημα είναι ότι αν και παράγεται ένα αντικείμενο τύπου // | Η απάντηση στο παραπάνω ερώτημα είναι ότι αν και παράγεται ένα αντικείμενο τύπου // | ||
Line 93: | Line 93: | ||
<code cpp ExceptionUse.cpp> | <code cpp ExceptionUse.cpp> | ||
#include < | #include < | ||
- | #include " | + | #include " |
using namespace std; | using namespace std; | ||
Line 112: | Line 112: | ||
} | } | ||
} catch(BaseException &ex) { | } catch(BaseException &ex) { | ||
- | cout << ex.what(); | + | cout << ex.message(); |
} catch(DerivedException &ex) { | } catch(DerivedException &ex) { | ||
- | cout << ex.what(); | + | cout << ex.message(); |
} | } | ||
return 0; | return 0; |
cpp/exception_inheritance.1588593890.txt.gz · Last modified: 2020/05/04 11:04 (external edit)