So there's a handsheet that my professor gave me as a guideline to follow. It gives us the prototype of the functions and that's IT. However, when I put in the prototype and fill in the body, an error comes up in regards to a conversion error. Any help?

Here's my code:

#include <iostream>
#include <string>
#include "Cust.h"	

using namespace std;

typedef Customer ItemType;

class LinkedList
{
	private:
		class Node 
		{
			public:
				ItemType info;
			    Node * next;
		};
		typedef Node * NodePointer;
	public:
		LinkedList();
		void insertItem(const ItemType &element);
		bool deleteItem(const ItemType &element);

	private:
		NodePointer first;
		int mySize;	
};

And my implementation file:

#include <iostream>
#include <fstream>
#include <string>
#include "LinkedList.h"

using namespace std;

LinkedList::LinkedList()
{
	first = 0;
	mySize = 0;
}

void LinkedList::insertItem(const ItemType &element)
{
	NodePointer ptr, prevPtr, newPtr;
	bool found;

	NodePointer newPtr = new Node(element);

	newPtr->next = 0;
	if(first == 0)
		first->next = newPtr;
		mySize++;
	if(first != 0)
	{
		first = ptr;
		found = false;
		while(ptr != 0 && !found)
		{
			if(ptr->info >= newPtr->info)
				found = true;
			else 
			{
				ptr = prevPtr;
				ptr->next = ptr;
			}
		}
	}
	if(ptr == first)
	{
		newPtr->next = first;
		first->next = newPtr;
		mySize++;
	}
	if(ptr != first)
	{
		prevPtr->next = newPtr;
		newPtr->next = ptr;
		mySize++;
	}
}

I know I probably won't finish this program as it is due in about 4 hours lol. But I would GREATLY appreciate it if someone helped me out as soon as they were able to. Thank you forum! :D

To make it easier for someone to help, please post the compiler error along with the code. Just saying that the compiler says that there is a conversion error is too vague. The only problem I can see be whatever code you have provided is that you have declared 'newPtr' twice in 'insertItem' function.

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.