[c++]Problem z mapa

0

Witam

Mam problem z mapa nastepujacej postaci

#include"node.h"
#include<set>
#include<map>
using namespace std;
bool compareMethod (const node &,const node &);

class nodeContainer{
		private:
			map<char,charNode> mapNode;	
			set<node> setNode;
		public:
		
			void addCharNode(char);
			void deleteCharNode(char);
			void parseString();
			void buildTree();
			charNode& getTreeTop();
			
};
#include "nodeContainer.h"
#include <iostream>
#include <string>
using namespace std;
bool compareMethod (const charNode& first,const charNode& second){
		bool retval;
		
		if((first.getVal())>=(second.getVal())) 
		{
			retval=true;
			
		}
		else 
		{	
			retval =  false;
		}
		return retval;
		
}
void nodeContainer::parseString(){
		string dane;
		char tst;
		cout<<"Podaj ciag znakow: ";
		
        getline(cin,dane);
        string::iterator itString;
		cout<<dane<<endl;
		cout<<"Znak nr 3 : "<<tst/*it[2]*/<<endl;
		
		for(itString=dane.begin();itString<dane.end();itString++){
			char tmp = *itString;
			charNode ola(tmp);
		if(mapNode.size()==0) mapNode[tmp]=ola;
		}
		
}
int main(void){
	
	nodeContainer p;
	p.parseString();

return 0;	
}

w tej linijce otrzymuje nastepujacy blad

if(mapNode.size()==0) mapNode[tmp]=ola;

/usr/include/c++/4.3/bits/stl_map.h error: no matching function for call to ‘std::charNode()’
node.h note: candidates are: std::charNode(const std::charNode&)
node.h note: std::charNode(char)
make: *** [nodeContainer] Błąd 1

Co to jest ta matchin function i co ona ma robic??

Pozdrawiam

0

EEE... a gdzie masz definicje charNode?
Ba definicję, nie ma nawet deklaracji.

0
namespace std{

	class charNode;
	enum nodeType {NUMERIC,LETTER};
	class node{
		private:
				charNode * ptrLeft;
				charNode * ptrRight;
				int val;
				bool parent;
		public:
				 int getVal()const;
				 bool hasParent()const;
				 void setParent();
				void setVal(int);
				charNode * getPtrLeft();
				void setPtrLeft(charNode*);
				charNode * getPtrRight();
				void  setPtrRight(charNode*);
				node();
				//node(const node&);
				//node& operator=(const node&);
				virtual nodeType getType(); 
				
				friend class charNode;
	};
	class charNode : public node{
		
		private:
		
				char charVal;

		public:
				charNode(char);
				char getCharVal();
				void setCharVal(char);
				nodeType getType();
				void incrementVal();
				charNode(const charNode&);
				charNode& operator=(const charNode&);
				
	};	
}

#include<iostream>
#include<string>
#include"node.h"
using namespace std;

nodeType node::getType(){
	return NUMERIC;
}
nodeType charNode::getType(){
	return LETTER;
}
 int node::getVal()const{
	return this->val;
}
void node::setVal(int newVal){
	val=newVal;
}
charNode* node::getPtrLeft(){
	return ptrLeft;
}
void node::setPtrLeft(charNode* newVal){
	  ptrLeft = newVal;
}
charNode* node::getPtrRight(){
	return ptrRight;
}
void node::setPtrRight(charNode* newVal){
	  ptrRight = newVal;
}
char charNode::getCharVal(){
	return charVal;
}
void charNode::setCharVal(char newVal){
	charVal = newVal;
}
bool node::hasParent()const{
	 return parent;
}
void node::setParent(){
	this->parent=true;
}
void charNode::incrementVal(){
	 val++;
}
node::node(){
		this->val = 0;
		this-> ptrLeft = NULL;
		this-> ptrRight=NULL;
		this->parent = false;
}
charNode::charNode(char znak){
	this->charVal = znak;
	this->val = 1;
}
charNode::charNode(const charNode& data){
		
		ptrLeft = data.ptrLeft;
		ptrRight = data.ptrRight;
		val = data.val;
		charVal = data.charVal;
}
charNode& charNode::operator=(const charNode& data){
		if(this==&data) return *this;
		
		ptrLeft = data.ptrLeft;
		ptrRight = data.ptrRight;
		val = data.val;
		charVal = data.charVal;
		
		return *this;
}

0

w skrócie nie zdefiniowałeś konstruktora domyślnego.

Poza tym czemu naruszasz przestrzeń nazw std? To jest przestrzeń nazw przeznaczona na standardowe biblioteki, a nie na twoje wypociny.

0

Witam

Racja to efekt frustracji...i kombinowania jak kon pod gore. Dzieki dziala

Pozdrawiam

1 użytkowników online, w tym zalogowanych: 0, gości: 1