[SOLVED] CS204-Homework 4 Constructors and Operator Overloading

30.99 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

This homework’s aim is to make you familiar with the fundamentals of Object-Oriented Programming: constructors, destructors and operator overloading. You will be given a sorted linked list class which you will be asked to create constructor, destructor and overload some operators.

 

 

Along with the PDF document, you are given a header file SortedArray.h and a corresponding cpp file SortedArray.cpp. Also another cpp file is supplied to you named Test.cpp for testing your code. You will be editing SortedArray.h and SortedArray.cpp files. You won’t be editing the Test.cpp file. Also output of the Test.cpp will be given so that you can check your code works correctly.

 

You need to implement (deep) copy constructor and destructor for SortedArray class. There are some comments in the given header and cpp files, use them as guidelines. You will also need to overload assignment (=) and plus (+) operators. After you implement copy constructor, destructor, assignment and addition operators, you should be able to do the following example operations.

 

SortedArray a2, a3, a4;

SortedArray a1(a2); // copy constructor

a4 = a1 + a2 + a3; // sorted arrays will be merged and result will also be sorted a1 = a1 + 10; // new integer value (in this case 10) will be inserted to sorted array  a2 = 5 + a1; // new integer value (in this case 5) will be inserted to sorted array a1 = a2 = a3; //cascading assignment

 

Output

Output of the Test.cpp is given in the following image, which is also provided in the output.txt file.

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.