Question: C++ code issue, I've tried this once already on here and didn't supply one specific detail. I need the driver to stay as I am

C++ code issue, I've tried this once already on here and didn't supply one specific detail. I need the driver to stay as I am supplying it. I won't supply the myArray.h file that I have, because it seems to complicate things.

\\driver.cpp

#include #include "myArray.h"

using namespace std;

int main() { myArray list1(5); myArray list2(5);

int i;

cout << "list1 : "; for (i = 0 ; i < 5; i++) cout << list1[i] <<" "; cout<< endl;

cout << "Enter 5 integers: "; for (i = 0 ; i < 5; i++) cin >> list1[i]; cout << endl;

cout << "After filling list1: ";

for (i = 0 ; i < 5; i++) cout << list1[i] <<" "; cout<< endl;

list2 = list1; cout << "list2 : "; for (i = 0 ; i < 5; i++) cout << list2[i] <<" "; cout<< endl;

cout << "Enter 3 elements: ";

for (i = 0; i < 3; i++) cin >> list1[i]; cout << endl;

cout << "First three elements of list1: "; for (i = 0; i < 3; i++) cout << list1[i] << " "; cout << endl;

myArray list3(-2, 6);

cout << "list3: "; for (i = -2 ; i < 6; i++) cout << list3[i] <<" "; cout<< endl;

list3[-2] = 7; list3[4] = 8; list3[0] = 54; list3[2] = list3[4] + list3[-2];

cout << "list3: "; for (i = -2 ; i < 6; i++) cout << list3[i] <<" "; cout<< endl;

if (list1 == list2) cout << " list 1 is equal to list2 " << endl; else cout << " list 1 is not equal to list2" << endl;

if (list1 != list2) cout << " list 1 is not equal to list2 " << endl; else cout << " list 1 is equal to list2" << endl;

//10% EXTRA CREDIT: UNCOMMENT CODE IF YOU'VE SUCCESSFULLY IMPLEMENTED THE FOLLOWING: //cout << list1<< (list1 == list2 ? " is equal to" : " not equal to ") << list2 << endl; //cout << list1<< (list1 != list2 ? " not equal to" : " is equal to ") << list2 << endl;

return 0; }

A.Add an overloaded operator!=() and operator==() functions.

B.Use the attached driver to test the program (lab6_Driver.cpp):

The Expected Output is:

list1 : 0 0 0 0 0

Enter 5 integers: 1 2 3 4 5

After filling list1: 1 2 3 4 5

list2 : 1 2 3 4 5

Enter 3 elements: 8 9 10

First three elements of list1: 8 9 10

list3: 0 0 0 0 0 0 0 0

list3: 7 0 54 0 15 0 8 0

list 1 is not equal to list2

list 1 is not equal to list2

Press any key to continue . . .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!