Im trying to find out if something is in this linked list function and if it is to return true and if not return false.
How do you find out if ThingType thing is in the list?

bool  Thelist::Search(ThingType thing) const
{
	Node* current;
	current=listPtr;

	while(current->thing != listPtr->thing)
	{
              
	}
}

//**************************************
my struct look like this

typedef Node* nodePtr;

struct Node
{
    ThingType thing;
    Nodeptr  next;
};

>How do you find out if ThingType thing is in the list?
Loop through all of the nodes and stop when you have a match. It's a basic linear search:

bool TheList::search ( ThingType thing )
{
  Node *it = listPtr;

  // Assuming your list is terminated with a null pointer
  while ( it != 0 ) {
    if ( it->thing == thing )
      break;

    it = it->next;
  }

  return it != 0;
}

That will return it true if its there and false if its not?

>That will return it true if its there and false if its not?
You tell me. I'm not here to do your work for you, so you'll have to put a little effort in and try to understand the algorithm.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.