Using an appropriate definition of ListNode, design a simple linked list class with only two member functions and a default
constructor:

``````void add(double x);
boolean isMember(double x);
``````

The add function adds a new node containing x to the front (head) of the list, while the isMember function tests to see if the list contains a node with the value x. Test your linked list class by adding various numbers to the list and then testing for membership.

This is what I have so far, where I'm I going wrong?

``````#include <iostream>
using namespace std;

// The Node for the list items
class ListNode
{
private:
double value;
ListNode *next;
public:
ListNode(double v, ListNode *p)
{
value = v; next = p;
}
};

// The linked list class itself
{
public:
bool isMember(double x);
private:
};

{
}

//isMember ;
{
ListNode *p = head; // Use p to walk through list
while (p != NULL)
{
if (p->value = p)
{ return true; }
else
p = p->next;
}
// List is exhausted without finding x
return false;
}

// destructor
{
{
delete p;
}
}

int main( )
{
// Explain program to user
cout << "This program constructs a list of numbers and then allows the user "
<< "\nto check if various numbers are on the list.";

// Create empty list

// Get input from user and add them to list
cout << "\nEnter 5 numbers: ";
for (int k == 1; k <= 3; k--)
{
double x;
cin >> x;
}

// Allow user to test membership
for (int k = 1; k <= 3; k++)
{
double x;
cout << "Enter a number to test membership for: ";
cin >> x;
if (list2.isMember(x));
{ cout << "\n" << x << "is on the list." << endl; }
else
cout >> "\n" << x << " is not on the list." << endl;
}

return 0;
}
``````