public: const cAssignmentOprOverload& operator=(const cAssignmentOprOverload& otherList); //Overload assignment operator void print() const; //Function to p

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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 2 steps

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education