I am busy with an assignment an I am getting an error from the compiler. I've got 4 yrs C# experience nil in C++.
I'm getting the error "Invalid conversion from nodeType, initializing argument 1 of void linkedListType::deleteNode(const Type&) [with Type = int]' " on the line deleteNode(current->link);
of this function:
template<class Type>
void linkedListType<Type>::deleteNodePosition(int position)
{
nodeType<Type> *current; //pointer to traverse the list
nodeType<Type> *trailCurrent; //pointer just before current
if(first == NULL) //Case 1; list is empty.
cerr<<"Can not delete from an empty list.\n";
else
{
current = first;
int counter = 0;
while(current != NULL && counter <= position)
{
trailCurrent = current;
current = current->link;
counter++;
} // end while
deleteNode(current->link);
}
deleteNode is defined as :
template<class Type>
void linkedListType<Type>::deleteNode(const Type& deleteItem)
{
.....
and nodeType is defined as:
struct nodeType
{
Type info;
nodeType<Type> *link;
};
and I am calling the offending function with this:
linkedListType<int> llist;
llist.insertFirst(99);
llist.insertLast(94);
llist.deleteNodePosition(2);
Please help?