Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Please write a c++ program and show all outputs. ------------------------------------------------------------The following are the requirements: Probe Define a probe that can be inserted into a

1. Please write a c++ program and show all outputs.

------------------------------------------------------------The following are the requirements:

Probe

Define a probe that can be inserted into a class as a test coverage device. The probe keeps track of the number of instances of the class that currently exist and how many have been created since the program was started. The probe is to respond with appropriate tracking information when the class instance containing the probe is queried. It will be necessary to figure out the best way to present the query. Demonstrate your probe on a class with multiple instances. Note: the data and function members of the probe cannot be static. The probe itself must be declared static in the probed class.

Overload the ostream operator to support printing of information of the class Probe.

Use the delete keyword to delete the copy constructor and assignment operator for the probe. (see Section 17.6.4 in Stroustrup)

Array

An array is a common structure for storing information. In many languages, one must specify the size of the array in advance of its use. Frequently, however, one does not know how much data will need to be stored. A common solution is to declare the array to be much larger than is expected to be necessary in hopes that it will be large enough. This is certainly not the most efficient solution.

Design an array that expands as data is entered, contracts when it is removed, and supports the following access methods:

// Overwrites an existing element, or adds a new element as necessary. // If an element exists at index, the existing element is overwritten. // If an element does not exist at the index, a new element is added. If necessary, the array // must expand to accommodate the new element. void put(int index, int value); // returns the element at index. int get(int index) const; // removes the element at the specified index. The array may contract. void remove(int index); 

Provide two overloads of operator[]:

Provide a const member function overload which returns the data at the specified array index.

Provide a non const member function overload which allows the data to be overwritten at the specified array index.

Write an overloaded ostream operator to display the contents of the array.

Write and test the copy constructor for the dynamic array class.

Write and test the assignment operator for the dynamic array class.

In this case, why is it better to write our own copy constructor and assignment operator rather than rely on the compiler generated ones?

In what situation might it be better to rely on the compiler generated copy constructor and assignment operators?

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions