QuestionQuestion

Design an Array class to operate on and store any number of floating-point values. Write a constructor to accept the amount of floating-point values to dynamically create and a destructor that performs the necessary cleanup and de-allocation. Write an overloaded operator function to perform addition on 2 objects with the same number of floating-point values. Overload the operator to simply add the corresponding floating-point values between two Array objects. In addition, write an overloaded operator function to perform addition between an Array object and a single floating-point value (add the float to each of the array values). Override the default copy constructor and assignment operator to perform a deep-copy. Lastly, overload the output stream operator to print the state of an Array object. Write a small application, similar to the one shown below, to test your class. Write your Array class in separate source and header files and the application in a separate file.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include "Array.h"

Array::Array() {
    head = NULL;
    size = 0;   
}

Array::Array(int amount) {
    head = NULL;
   
    size = amount;
    if (amount > 0) {
       head = new Node;
      
       head->next = NULL;
       head->value = 0;
       Node * current = head;
      
       for (int i = 0; i < amount - 1; i++) {
            Node * tmp = new Node;
            tmp->next = NULL;
            tmp->value = 0;
            current->next = tmp;
            current = current->next;
       }// end for
    }// end if...
$35.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats