Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <stdexcept>
- using namespace std;
- int main() {
- vector<int> test;
- test.push_back(1);
- test.push_back(2);
- test.push_back(3);
- cout << test[0] << endl;
- cout << test[1] << endl;
- cout << test[2] << endl;
- cout << test.at(3) << endl;
- cout << test[3] << endl;
- try {
- cout << test.at(3) << endl;
- }
- catch (const exception &e) {
- cout << "Out of range hein tu veux un dessin ??!!!" << endl;
- cout << "Ton tableau ne comporte que " << test.size() << " élements!" << endl;
- cout << e.what() << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment