I truly don't understand what this assignment is asking, and this is it

design a simple linked list class with only two member functions and a default constructor:
void add(double x);
boolean isMember(double x);
LinkedList( );
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 numebrs to the list and then testing for membership.

and what i have is

#include <iostream>
using namespace std;

struct ListNode
  double value;
  ListNode *next;

int main()
   ListNode *head;

   // Create first node with 12.5--step 1
   head = new ListNode;    // Allocate new node
   head->value = 12.5;     // Store the value
   head->next = NULL;      // Signify end of list

   // Create second node with 13.5—step 2
   ListNode *secondPtr = new ListNode;
   secondPtr->value = 13.5;
   secondPtr->next = NULL;  // Second node is end of list
   head->next = secondPtr;  // First node points to second

   // Print the list.
   cout << "First item is " << head->value << endl;
   cout << "Second item is " << head->next->value << endl;
   return 0;
5 Years
Discussion Span
Last Post by caut_baia

Do you have a LinkedList class with members LinkedList::add(), LinkedList::isMember(), and LinkedList::LinkedList()? If you do, I can't find them.

So, no, it does not.


You should really read about the logic of linked list which is nothing more than a row of nodes in which every node contains a pointer to the next.Imagine a neckalce made of marbles.Your assignment specifies that you should create linked list which implies creating a data structure named LinkedList in which you can store nodes(ListNode) , structure which should contain functions that manipulates nodes (Add(),IsMember()).
Your node structure looks ok for now so you can start creating another structure named LinkedList which declares data memebers of type ListNode and functions for manipulating nodes.By then you'll be almost done.Come back with some more code and you'll recieve more help.

Votes + Comments
Well done, you're starting to get the idea. :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.