Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Arr_ope
- {
- public:
- int arr[5] = {1, 3, 5, 5, 6};
- void arrOperation(int value, int pos)
- {
- arr[pos] = value;
- }
- };
- class my_exception
- {
- };
- int main()
- {
- Arr_ope ar;
- int pos;
- int value;
- cout << "\n Enter value to be added in array: ";
- cin >> value;
- cout << "\n Enter position where value is to added: ";
- cin >> pos;
- if (pos > 5)
- {
- try
- {
- throw my_exception();
- }
- catch (my_exception t)
- {
- cout << "\n\n Caught Exception of my_exception class" << endl;
- cout << "\n Trying to access out of range position of Array";
- }
- }
- ar.arrOperation(value, pos);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement