Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

d. blackboard.com/webapps/blackboard/content/listContentjsp?course id bs Lab 12 Create a template class called MyArray that implements an array and works with any type (int, double, etc.). The

image text in transcribed
d. blackboard.com/webapps/blackboard/content/listContentjsp?course id bs Lab 12 Create a template class called MyArray that implements an array and works with any type (int, double, etc.). The constructor should take a size for the amay and use new to allocats memory (don't forget to delete in the destructor). Overload operatorll to access the elements of the array If an attempt is made to access an elerment outside the array bounds (either above OR below), throw an exception In the main program, first create a MyArray inb object, add a few values, and demonstrate that operatord throws an std out of range If an attempt is made to access an out-of-bounds element (out-of-bounds means above OR below the array bounds) Catch the exception and print an appropriate message Then do the same thing with an MyArray std::string>. Be sure to test both GOOD and BAD index values. Include this header file #include Hint you will need both of these overloads, which will have identical implementations (something along the lines of r sometning) return a vealue) const T& operatorint ) const Note that both of these operator) overloads return a roference to an object of type Your MyArrey dass has an aray of these objects For example to reum a reforenceto the ft element in the array, you would use return arrayfo Optional Challenge: Create a method called void CheckBounds(int) that simply returns if is a valid subscript for the array, and throws a std out of range exception otherwise Use this method in your operator overleads Cheakist 1. Project/solution named correctly 2. Correct comments at top 3. Consistent indentation (Use Edti/Advanced/Format Document 4 Good variable names 5. Overall neat organization 6 Comments in code explain what's being done 7 Correct division of code into h and cpp files 8. Use of Mpragma once in h fles (or, Bifndef) 9 #include "stdafr h-in cpp files (or, suppress pch) 10. Test for below as well as above out-of-range Lab 13 etc) 634 d tor nililel alues 0 to 9 (datalo)0 datol

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

List the activities involved in employer-designed HRD programs

Answered: 1 week ago