/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
practical_exercises/10_day_practice/day9/exception/9.cpp
45 строк
1 KB
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
// Eg10-12.cpp #include <iostream> using namespace std; class BasicException { public: char *Where() { return "BasicException..."; } }; class FileSysException : public BasicException { public: char *Where() { return "FileSysException..."; } }; class FileNotFound : public FileSysException { public: char *Where() { return "FileNotFound..."; } }; class DiskNotFound : public FileSysException { public: char *Where() { return "DiskNotFound..."; } }; int main() { try { // ..... //程序代码 throw FileSysException(); } catch (DiskNotFound p) { cout << p.Where() << endl; } catch (FileNotFound p) { cout << p.Where() << endl; } catch (FileSysException p) { cout << p.Where() << endl; } catch (BasicException p) { cout << p.Where() << endl; } try { // ..... //程序代码 throw DiskNotFound(); } catch (BasicException p) { cout << p.Where() << endl; } catch (FileSysException p) { cout << p.Where() << endl; } catch (DiskNotFound p) { cout << p.Where() << endl; } catch (FileNotFound p) { cout << p.Where() << endl; } }