Question
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.
template
void DoublyLinkedList
{
if (front == nullptr)
{
cout
return;
}
if (index > count)
{
cout
return;
}
if (index == 0)
{
shared_ptr
front = front->forward;
delete temp;
if (count == 0)
{
front = nullptr;
back = nullptr;
count--;
return;
}
count--;
return;
}
if (index == count-1)
{
shared_ptr
shared_ptr
int tracker = 0;
while (tracker
{
temp = cur;
cur = cur->forward;
tracker++;
}
delete cur;
back = temp;
back->backward = nullptr;
count--;
return;
}
shared_ptr
shared_ptr
int tracker = 0;
while (tracker
{
temp = cur;
cur = cur->forward;
tracker++;
}
temp->forward = cur->forward;
delete cur;
count--;
}
delete icrp frontullptri back-ackward nullptrStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started