CJCoding With Joseph
15per day

Safe List Access

Create a class SafeList that wraps a vector<int> and prevents out-of-bounds access.

Requirements:
1. Constructor SafeList(): already provided
2. void add(int value): adds value to the internal vector
3. int get(int index) const: if index is out of bounds, throw a std::out_of_range with the message "Index out of bounds". Otherwise return the element at that index.

Do NOT write a main function.

Expected Output:

10
Topics:
ClassesExceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.