Commit 60cd82b9 authored by Šmelko Adam Mgr.'s avatar Šmelko Adam Mgr.
Browse files

cv10

parent 3822be02
......@@ -32,6 +32,7 @@ Deadliny:
| 18.11.2021 | Polymorfní datové struktury | [CV7](https://gitlab.mff.cuni.cz/teaching/nprg041/Smelko/cpp-cvika/-/blob/master/prezentacie/Cv7.pdf) |
| 25.11.2021 | Šablony | [CV8](https://gitlab.mff.cuni.cz/teaching/nprg041/Smelko/cpp-cvika/-/blob/master/prezentacie/Cv8.pdf) |
| 02.12.2021 | Gumové pole, 2. DÚ | [CV9](https://gitlab.mff.cuni.cz/teaching/nprg041/Smelko/cpp-cvika/-/blob/master/prezentacie/Cv9.pdf) |
| 09.12.2021 | Výjimky, streamy a manipulátory | [CV10](https://gitlab.mff.cuni.cz/teaching/nprg041/Smelko/cpp-cvika/-/blob/master/prezentacie/Cv10.pdf) |
## Úkoly:
......
#include <stdexcept>
#include <iostream>
struct X
{
~X() {std::cout << "X destructed" << std::endl;}
};
struct Y
{
~Y() {std::cout << "Y destructed" << std::endl;}
};
void g()
{
Y y;
throw std::runtime_error("e");
}
void f()
{
X x;
g();
X x2;
}
int main()
{
try {
f();
}
catch (std::runtime_error& e)
{
std::cout << "caught std::runtime_error" << std::endl;
}
catch (std::exception& e)
{
std::cout << "caught std::exception" << std::endl;
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment