Я не могу удалить последний элемент из простого связанного списка с этой реализацией. Чего мне не хватает?
void MyList<T>::deleteE(int poz) {
auto nCurent = head;
int lg = 0;
while (lg < poz || nCurent->next != nullptr) {
nCurent = nCurent->next;
lg++;
}
if (poz == 0) {
auto aux = this->head;
this->head = head->urm;
delete aux;
}
if (nCurent->next == nullptr) {
delete nCurent;
}
else {
auto aux = nCurent->next;
nCurent->next= aux->next;
delete aux;
}
}