By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

Need Help on passing linked list head node to function

P: 2
template<class T>
struct NODE
{
T data;
NODE<T> * next;
};

template<typename T>
NODE<T>* QuickSortList( NODE<T>* list )
{}

// CS556QuickSort.cpp : Defines the entry point for the console
application.
//

#pragma once
#include "stdafx.h"
#include <iostream>
#include "QuickSort.h"
#include "LinkedList.h"
#include <list>
using namespace std;



void TestQuickSort()
{
int i = 10; // counter

List<int> iList; // I have my own likked list class

while( i > 0 )
{
iList.push_back(i);
i--;
}
cout << "UNSORTED LIST" << endl;
cout << "*********************************" << endl;
iList.print();

Node<int>* ListHead = iList.HeadNode();
Node<int>* SortedList = NULL;


SortedList = QuickSortList<int>(ListHead);
cout << "SORTED LIST" << endl;
cout << "*********************************" << endl;
}


int _tmain(int argc, _TCHAR* argv[])
{
TestQuickSort();
return 0;
}



I'm not giving so far implementation of QuickSortList function.
The problem comes when execution reaches at point

SortedList = QuickSortList<int>(ListHead); he error is: cannot convert parameter 1 from 'Node<T> *'
to 'NODE<T> *'

Help me to understand what I'm doing wrong.
Dec 10 '06 #1
Share this Question
Share on Google+
1 Reply


DeMan
100+
P: 1,806
You have declared your template to deal with NODE items. SortedList is declared Node so when you try to pass it back a NODE, the compiler complains......

In fact, the compiler is complaining that ListHead is a Node, when you are expecting a NODE (but I think when you fix that you'll find it complains abut what is mentioned above.....
Dec 10 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.