C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 8th, 2010, 07:15 PM
bajan_elf bajan_elf is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 2 bajan_elf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m
Reputation Power: 0
General - "No matching function for call to" error

Hi,

I'm getting an error when running my program. Almost all of the functions are coded in C++, but the GUI is coded using wxwidgets. The following code is for a Binary Heap Tree and the issue I'm having is with the Swap function. The two lines in the Swap function which should call the setData function is producing the error "no matching function for call to setData.

The Swap function is only being called by the Heapify function. I've also included the class structures for the heap and the node.

Code:
#ifndef HEAP_H
#define HEAP_H

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

using namespace std;


class HNode
{
	private:
		long int guestID;
		char name[15];
		char surname[15];
		char payment[5];
		int days;
		char roomType[10];
		int roomNo;
		char purpose[10];
		//int Count;
		
		HNode* LChild;
		HNode* RChild;
		HNode* Parent;

	public:
		HNode(Record);

		long getID(){return guestID;}
		char* getName(){return name;}
		char* getSurname(){return surname;}
		char* getPayment(){return payment;}
		int getDays(){return days;}
		char* getRoomType(){return roomType;}
		int getRoomNo(){return roomNo;}
		char* getPurpose(){return purpose;}
		//int getCount(){return Count;};
		
		HNode* getLChild(){return LChild;};
		HNode* getRChild(){return RChild;};
		HNode* getParent(){return Parent;};
		string getData();
		
		void setData(HNode);
		//void setCount(int count){Count = count;};
		void setLChild(HNode* lchild){LChild = lchild;};
		void setRChild(HNode* rchild){RChild = rchild;};
		void setParent(HNode* parent){Parent = parent;};
};

HNode::HNode(Record rec)
{
	guestID = rec.guestID;
	strcpy(name, rec.name);
	strcpy(surname, rec.surname);
	strcpy(payment, rec.payment);
	days = rec.days;
	strcpy(roomType, rec.roomType);
	roomNo = rec.roomNo;
	strcpy(purpose, rec.purpose);

	setLChild(NULL);
	setRChild(NULL);
	setParent(NULL);
}

	
void HNode::setData(HNode rec)
{
	guestID = rec.guestID;
	strcpy(name, rec.name);
	strcpy(surname, rec.surname);
	strcpy(payment, rec.payment);
	days = rec.days;
	strcpy(roomType, rec.roomType);
	roomNo = rec.roomNo;
	strcpy(purpose, rec.purpose);
}

string HNode::getData()
{
	string str;
	char idNum[7];
	char day[3];
	char room[5];
	int kount = 0;
		
	str.clear();
	sprintf(idNum,"%ld", guestID);  	//Write those integer values to strings
	sprintf(day,"%d", days);	
	sprintf(room,"%d", roomNo);

	str.append(idNum);
	str.append(" ");
	formatString(name, 15);
	str.append(name);
	str.append(" ");
	formatString(surname, 15);
	str.append(surname);
	str.append(" ");    
	formatString(payment, 5);
	str.append(payment);
	str.append(" ");
	formatString(day, 3);
	str.append(day);
	str.append(" ");
	formatString(room,5);
	str.append(room);
	str.append(" ");
	str.append(purpose);
	str.append("\n");

	return str;
}


class BHT
{
	private:
		HNode *head;
		string heapSortHelper( HNode* node );
		void addHelper( HNode* node, Record rec );

	public:
		BHT(){setHead(NULL);};
		void setHead(HNode *node){head = node;};
		HNode* getHead(){return head;};
		
		void Add(Record);
		void Insert(HNode *temp, HNode* node);
		void Heapify(HNode *node);
		void Swap(HNode *node, HNode *node2);
		string heapSort();
};

void BHT::Add(Record rec)
{
	addHelper( head, rec);
}

void BHT::addHelper(HNode* node, Record rec)
{
	HNode* temp = new HNode(rec);
	
	if(getHead() == NULL)	
		setHead(temp);
	else
		Insert(temp, getHead());
}


void BHT::Insert(HNode* temp, HNode* node)
{
	if(node->getLChild() == NULL)
	{
		node->setLChild(temp);
		temp->setParent(node);
		Heapify(temp);
	}
	else if(node->getRChild() == NULL)
	{
		node->setRChild(temp);
		temp->setParent(node);
		Heapify(temp);
	}
	else if(node->getLChild() != NULL && node->getLChild()->getRChild() != NULL)
		Insert(temp, node->getRChild());
	else
		Insert(temp, node->getLChild());
}


void BHT::Heapify(HNode *node)
{
	HNode *temp;
	
	if(node == NULL || node->getParent() == NULL)
		return;
	else if(node->getData() > node->getParent()->getData())
	{
		Swap(node, node->getParent());
		Heapify(node->getParent());
	}
}

 void BHT::Swap(HNode *node, HNode *node2)
 {	
 	HNode temp = *node2;
 
 	node2->setData(node->getData()); //issue is here
 	node->setData(temp.getData()); //and here
 }


#endif


Any help would be appreciated. It's the only thing that's stopping me from finishing this. Thanks.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - "No matching function for call to" error


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap