469,621 Members | 1,720 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

Need Help on passing linked list head node to function

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

#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 )
cout << "UNSORTED LIST" << endl;
cout << "*********************************" << endl;

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[])
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
1 2384
1,806 1GB
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.

Similar topics

11 posts views Thread by C++fan | last post: by
10 posts views Thread by Ben | last post: by
13 posts views Thread by XXXXXX.working.in.my.blood | last post: by
1 post views Thread by drewy2k12 | last post: by
6 posts views Thread by Jim Showalter | last post: by
9 posts views Thread by Sheldon | last post: by
8 posts views Thread by dmp | last post: by
reply views Thread by Atos | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.