Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <numeric>
- using namespace std;
- class C
- {
- vector<int> vals;
- public:
- C(const vector<int>& given): vals(given)
- {
- if (any_of(begin(vals), end(vals), [](int v) {return v < 0; }))
- {
- throw runtime_error("negative values!");
- //vals гарантировано будет уничтожена
- }
- }
- ~C() // если объект был создан
- {
- // то vals уничтожится здесь
- }
- };
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement