โ Back to Classes
Question 148
Safe List Access
Safe List Access
Create a classSafeListthat wraps avector<int>and prevents out-of-bounds access. Requirements: 1. ConstructorSafeList(): already provided 2.void add(int value): adds value to the internal vector 3.int get(int index) const: ifindexis out of bounds, throw astd::out_of_rangewith 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.