Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Help. How to delet from shared pointer. I want to delete temp and cur. template void DoublyLinkedList ::deleteAtIndex(const unsigned int index) { if (front

C++ Help. How to delet from shared pointer. I want to delete temp and cur.image text in transcribed

template

void DoublyLinkedList::deleteAtIndex(const unsigned int index)

{

if (front == nullptr)

{

cout

return;

}

if (index > count)

{

cout

return;

}

if (index == 0)

{

shared_ptr> temp(front);

front = front->forward;

delete temp;

if (count == 0)

{

front = nullptr;

back = nullptr;

count--;

return;

}

count--;

return;

}

if (index == count-1)

{

shared_ptr> temp(nullptr);

shared_ptr> cur(front);

int tracker = 0;

while (tracker

{

temp = cur;

cur = cur->forward;

tracker++;

}

delete cur;

back = temp;

back->backward = nullptr;

count--;

return;

}

shared_ptr> temp(nullptr);

shared_ptr> cur(front);

int tracker = 0;

while (tracker

{

temp = cur;

cur = cur->forward;

tracker++;

}

temp->forward = cur->forward;

delete cur;

count--;

}

delete icrp frontullptri back-ackward nullptr

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

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago