Question
Consider the definition of a class that acts like an array with bounds-checking. class my_array { }; private: public: int size; int *a; my_array
Consider the definition of a class that acts like an array with bounds-checking. class my_array { }; private: public: int size; int *a; my_array (int s): size (s) { a = new int[size]; } int &operator[] (int i); int get_size() { return size; } a) Give the code for my array's operator[] method, as one would define it outside the class. (3 Marks). b) Overload the insertion ( < >) operators so that they behave as follows: i. 11. The insertion operator outputs all the elements of the array, separated by spaces. to the output stream. (3 Marks) The extraction operator reads the elements of the array from the input stream. (3 Marks).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Practical Introduction To Data Structures And Algorithm Analysis Java Edition
Authors: Clifford A. Shaffer
1st Edition
0136609112, 978-0136609117
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App