This exercise will enhance your understanding of classes and operator overloading. Using the provided two files: classAssignmentOverloadh (gives the full definition of the class) and testProgAssignmentOpr.cpp (is the main entry point to the class usage). Do not modify any of the two files. Note that the class contains a list of integers. A member length integer which indicates the actual size of the list and another "maxSize" which indicates the maximum size that the list could read. "maxSize" is set by the constructor. "length" is kept track of when filling the list dynamically. Your job is to write the definition of the member functions defined classAssignmentOverload.h such that a- print" member method prints a message telling the user that the list is empty or prints the content of the list which is a list of integers space separated. b- "insetEnd" should wam the user if trying to insert more than the defined capacity of the list or inserts an integer into the end of the list. c- "destoryList" deallocates the content of the list and resets other members accordingly. d- The constructor creates a list of "maxSize" and should wam if maxSize is 0. e The overloaded =" operator should create a copy of the list of the same size and the same content. It should not be a simple pointer assignment which C++ does by default. f- The output should look like this: Line 15: Enter 5 integers: 19 18 3 29 Line 19: intList1: 19 18 3 2 9 Line 22: intList2: 19 18 3 29 Line 26: intList2: The list is empty. Line 28: After destroying intList2, intList1: 19 18 3 29 Line 30: After destroying intList2, intList3: 19 18 3 2 9

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

c++ (the question in the photo,plz don't tell me that you are not able to solve it, take your time and solve it all)

class cAssignmentOprOverload
{
public:
const cAssignmentOprOverload&
operator=(const cAssignmentOprOverload& otherList);
//Overload assignment operator

void print() const;
//Function to print the list

void insertEnd(int item);
//Function to insert an item at the end of the list
//Postcondition: if the list is not full, length++;
// list[length] = item
// if the list is full
// output an appropriate message
void destroyList();
//Function to destroy the list
//Postcondition: length = 0; maxSize = 0;
// list = NULL

cAssignmentOprOverload(int size = 0);
//constructor
//Postcondition: length = 0; maxSize = size;
// list is an arry of size maxSize

private:
int maxSize;
int length;
int *list;
};

 

 

 

#include <iostream>

#include "classAssignmentOverload.h"

using namespace std;

int main()
{
cAssignmentOprOverload intList1(10); //Line 10
cAssignmentOprOverload intList2; //Line 11
cAssignmentOprOverload intList3; //Line 12

int i; //Line 13
int number; //Line 14

cout << "Line 15: Enter 5 integers: "; //Line 15

for (i = 0; i < 5; i++) //Line 16
{
cin >> number; //Line 17
intList1.insertEnd(number); //Line 18
}

cout << endl << "Line 19: intList1: "; //Line 19
intList1.print(); //Line 20

intList3 = intList2 = intList1; //Line 21

cout << "Line 22: intList2: "; //Line 22
intList2.print(); //Line 23

intList2.destroyList(); //Line 24

cout << endl; //Line 25
cout << "Line 26: intList2: "; //Line 26
intList2.print(); //Line 27

cout << "Line 28: After destroying intList2, "
<< "intList1: "; //Line 28
intList1.print(); //Line 29

cout << "Line 30: After destroying intList2, "
<< "intList3: "; //Line 30
intList3.print(); //Line 31
cout << endl; //Line 32

return 0;
}

 

 

 

 

This exercise will enhance your understanding of classes and operator overloading.
Using the provided two files: classAssignmentOverload.h (gives the full definition of
the class) and testProgAssignmentOpr.cpp (is the main entry point to the class usage).
Do not modify any of the two files. Note that the class contains a list of integers. A
member length integer which indicates the actual size of the list and another
"maxSize" which indicates the maximum size that the list could read. "maxSize" is
set by the constructor. "length" is kept track of when filling the list dynamically. Your
job is to write the definition of the member functions defined
classAssignmentOverload.h such that
a- "print" member method prints a message telling the user that the list is empty
or prints the content of the list which is a list of integers space separated.
b- "insetEnd" should wam the user if trying to insert more than the defined
capacity of the list or inserts an integer into the end of the list.
c- "destoryList" deallocates the content of the list and resets other members
accordingly.
d- The constructor creates a list of "maxSize" and should wam if maxSize is 0.
e- The overloaded "=" operator should create a copy of the list of the same size
and the same content. It should not be a simple pointer assignment which C+
does by default.
f The output should look like this:
Line 15: Enter 5 integers: 19 18 3 29
Line 19: intList1: 19 18 3 29
Line 22: intList2: 19 18 3 29
Line 26: intList2: The list is empty.
Line 28: After destroying intList2, intList1: 19 18 3 29,
Line 30: After destroying intList2, intList3: 19 18 3 2 9
Transcribed Image Text:This exercise will enhance your understanding of classes and operator overloading. Using the provided two files: classAssignmentOverload.h (gives the full definition of the class) and testProgAssignmentOpr.cpp (is the main entry point to the class usage). Do not modify any of the two files. Note that the class contains a list of integers. A member length integer which indicates the actual size of the list and another "maxSize" which indicates the maximum size that the list could read. "maxSize" is set by the constructor. "length" is kept track of when filling the list dynamically. Your job is to write the definition of the member functions defined classAssignmentOverload.h such that a- "print" member method prints a message telling the user that the list is empty or prints the content of the list which is a list of integers space separated. b- "insetEnd" should wam the user if trying to insert more than the defined capacity of the list or inserts an integer into the end of the list. c- "destoryList" deallocates the content of the list and resets other members accordingly. d- The constructor creates a list of "maxSize" and should wam if maxSize is 0. e- The overloaded "=" operator should create a copy of the list of the same size and the same content. It should not be a simple pointer assignment which C+ does by default. f The output should look like this: Line 15: Enter 5 integers: 19 18 3 29 Line 19: intList1: 19 18 3 29 Line 22: intList2: 19 18 3 29 Line 26: intList2: The list is empty. Line 28: After destroying intList2, intList1: 19 18 3 29, Line 30: After destroying intList2, intList3: 19 18 3 2 9
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY