bool delete_element(int a) {
LinkedList* prev = head;
LinkedList* current = head_pNextValue;
while(current != NULL) {
if(current_value == a) {
break;
}
else {
cout << "Value " << current_value << " does not match " << a << ".\n";
prev = current;
current = current_pNextValue;
}
}
if(current == NULL) {
cout << "Can't remove value: no match found.\n";
} else {
cout << "Deleting: " << current << "\n";
prev->pNextValue = current_pNextValue;
delete current;
}
}
list<int> myList;
bool isempty(){
if (myList.empty())
cout << "my list is empty\n";
else
cout << "my list isn’t empty\n";
}
Comments
Leave a comment