473,513 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help on passing linked list head node to function

2 New Member
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
1 2621
DeMan
1,806 Top Contributor
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

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

Similar topics

11
3076
by: C++fan | last post by:
Suppose that I define the following class: class example_class{ public: example_class(); void funtion_1(); void function_2(); protected:
10
15100
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
10
2495
by: Ben | last post by:
Hi, I am a newbie with C and am trying to get a simple linked list working for my program. The structure of each linked list stores the char *data and *next referencing to the next link. The...
13
2167
by: XXXXXX.working.in.my.blood | last post by:
hi all, i need help with linked lists... the problem is this, "reverse the contents of a singly linked list without using a temporary node"... solution with code will be appreciated...
1
1784
by: drewy2k12 | last post by:
Heres the story, I have to create a doubly linked list for class, and i have no clue on how to do it, i can barely create a single linked list. It has to have both a head and a tail pointer, and...
6
10122
by: Jim Showalter | last post by:
I'm trying to write code that gets fixed-length strings from the user and then stores them in a linked list. Here's the definition of my list node: struct node {char str; struct node* next; };...
9
4884
by: Sheldon | last post by:
Hi, I am trying to understand linked lists and the different ways to write a linked list and double linked list. I have been trying to get this function called insert_word to work but to no...
8
718
by: dmp | last post by:
What are Linked list? Please somebody show some ready made programs of linked list
1
2350
by: vekka | last post by:
Hi! Programming language: C I wondered if any of you are able to see what is wrong with my code. What I want to do is to find the union of a set of numbers. I use a singly linked list. and my union...
0
8611
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7527
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5090
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.