Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS THE DRIVER DI NOT ALTER. I dint know why my code wont cout the sample givet at the bottom of the code. #include

THIS IS THE DRIVER DI NOT ALTER. I dint know why my code wont cout the sample givet at the bottom of the code.

#include

#include "List.h"

using namespace std;

int main()

{

int orig[] = {6,3,5,1,8,4,7};

List list1(orig, 7, 50);

cout "list1 created from array: " endl;

list1.display(cout);

cout endl;

int orig2[] = {1,5,15,23,3};

List list2(orig2, 5, 5);

cout "list2 created from array: " endl;

list2.display(cout);

cout endl;

cout "Capacity of list2 is " list2.getCapacity() endl;

cout "Change the capacity of list 2 to 50." endl;

list2.ChangeCapacity(50);

cout "After the change of capacity, list2 becomes: " endl;

list2.display(cout); // Should be unchanged, since we change the capacity, not the contents

cout endl;

cout "Inserting more elements to the expanded list2." endl;

for(int i=0; i45; i++){

list2.insert(i,0);

}

cout "After the insertion, list2 becomes: " endl;

list2.display(cout);

// Should be 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 5 15 23 3

cout endl;

}

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
\#include \#include "List. h" using namespace std; 10. void List::insert(ElementType item, int pos) \{ if (mySize == myCapacity) exit(1); if (pos mySize) return; I/ shift array elements right to make room for item for (int i= mySize; i> pos; i) myArrayPtr [i]= myArrayPtr [i1]; /I insert item at pos and increase list size myArrayPtr [pos] = item; mySize++; // don't forget this! \} void List: :erase(int pos) \{ if (pos = mySize) return; I/ shift array elements left for (int i= pos; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions

Question

What steps should be taken to address any undesirable phenomena?

Answered: 1 week ago