public: const cAssignmentOprOverload& operator=(const cAssignmentOprOverload& otherList); //Overload assignment operator void print() const; //Function to p
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;
}
Step by step
Solved in 2 steps