07. List
Здравейте! Изпитвам затруднения със задача 07. List от упражнението за правилото на 3/5/0. И по-точно с имплементирането на функцята static List getReversed(List l) и деструктора. Когато рънна програмата ми изписва exit code -1073741819, което до колкото разбрах е от неправилно освобождаване на памет. Чудя се дали не трябва да напиша някаква функция за изтриването и на всеки нов Node, който създавам или той сам ще се изтрие, когато излезе от скоуп. Ето го кода ми ще съм благодарна на малко помощ:
#include "List.h"
#include <sstream>
List::List()=default;
List::List(const List& other){
 *this = other;
}
int List::first() const{
    return head->getValue();
}
void List::add(int value){
    Node* newV;
    newV->setValue(value);
    newV->setPrev(tail);
    newV->setNext(nullptr);
    Node* help=newV;
    newV=tail;
    tail=help;
    newV->setNext(tail);
}
void List::addAll(const List& other){
   tail->setNext(other.head);
   other.head->setPrev(tail);
}
void List::removeFirst(){
    Node* newFirst=head->getNext();
    Node* help = tail;
    tail=newFirst;
    newFirst=tail;
}
void List::removeAll(){
    head->setNext(nullptr);
    head->setValue(0);
    tail->setPrev(head);
    tail->setValue(0);
}
size_t List::getSize() const{
    if(isEmpty()){return 0;}
    size_t size=1;
    Node* curr=head;
    while(curr!=tail){
        curr=head->getNext();
      size++;
    }
    return size;
}
bool List::isEmpty() const{
    if(head->getNext()==nullptr){
        return true;
    }
    return false;
}
List List::getReversed(List l){
    //??
   return l;
}
std::string List::toString() const{
    Node* curr=head;
    std::ostringstream out;
    while(curr!=tail||curr==tail){
        out<<curr->getValue()<<" ";
    }
    return out.str();
}
List& List::operator<<(const int& value){
    add(value);
    return *this;
}
List& List::operator<<(const List& other){
    addAll(other);
    return *this;
}
List& List::operator=(const List& other){
    head=other.head;
    tail=other.tail;
    size=other.size;
    return *this;
}
List::~List() {
    //??
    Node *curr = head;
    while (curr != tail) {
        curr = curr->getNext();
        delete curr->getPrev();
        curr->setPrev(nullptr);
    }
    delete curr;
    curr = nullptr;
}
//Node part
List::Node::Node(int value, Node * prev, Node * next){
    this->value=value;
    this->next=next;
    this->prev=prev;
}
int List::Node::getValue() const{
    return this->value;
}
void List::Node::setValue(int value){
    this->value=value;
}
List::Node* List::Node::getNext() const{
    return this->next;
}
void List::Node::setNext(Node * next){
    value=next->value;
    next=next->next;
    prev=next->prev;
}
List::Node * List::Node::getPrev() const{
    return this->prev;
}
void List::Node::setPrev(Node * prev){
    value=prev->value;
    next=prev->next;
    prev=prev->prev;
}