Question: Add in code to complete the Remove method in the following code. Submit a zip of the completed code along with a * . vcxproj

Add in code to complete the Remove method in the following code.
Submit a zip of the completed code along with a *.vcxproj file (if you're using a windows system).
#include
using namespace std;
struct node
{
int data;
struct node* next;
};
class LinkIntList
{
private:
struct node* head;
public:
LinkIntList()
{
head = nullptr;
}
void Add(int x)
{
struct node* newNode = new struct node;
newNode->next = head;
newNode->data = x;
head = newNode;
}
// removes the first node with the value x
// returns true if successful
// returns false if value x isn't found
bool Remove(int x)
{
// Add your code here
}
void PrintAll()
{
struct node* ptr = head;
while (nullptr != ptr)
{
cout << ptr->data <<"";
ptr = ptr->next;
}
cout << endl;
}
};
int main()
{
LinkIntList list;
for (int i=0; i<10; i++)
// populate the list with numbers 0..9
list.Add(i);
list.Remove(10);
list.Remove(9);
list.Remove(7);
list.Remove(0);
list.Remove(4);
list.PrintAll();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!