When I run this
#include <iostream>
#include<queue>
#include<vector>
#include<iomanip>
#include<string>
using namespace std;
string decode(NodePtr root, string encoded_str)
{
string temp = "";
int i;
for(i = 0 ; i < encoded_str.size() ; i++)
{
if(root == NULL ){
cout<< "not possible , error in encoded_str" << endl;
return temp;
}
if(encoded_str[i]=='0')
root= root->left ;
else
root= root->right ;
if(node->is_leaf()){
temp+=root->letter;
return temp;
}
}
}
int main()
{
decode(*Huffmantree, "10010101010");
system("pause");
return 0;
}
I get the some undefined errors,
Also there was a quotation error on line 18 I changed.
7 IntelliSense: identifier "NodePtr" is undefined c:\Users\Evan\Documents\Visual Studio 2012\Projects\huffman\huffman\Source.cpp 10 15 huffman
8 IntelliSense: identifier "node" is undefined c:\Users\Evan\Documents\Visual Studio 2012\Projects\huffman\huffman\Source.cpp 29 12 huffman
9 IntelliSense: identifier "Huffmantree" is undefined c:\Users\Evan\Documents\Visual Studio 2012\Projects\huffman\huffman\Source.cpp 42 10 huffman
Error 5 error C2447: '{' : missing function header (old-style formal list?) c:\users\evan\documents\visual studio 2012\projects\huffman\huffman\source.cpp 11 1 huffman
Error 2 error C2146: syntax error : missing ')' before identifier 'root' c:\users\evan\documents\visual studio 2012\projects\huffman\huffman\source.cpp 10 1 huffman
Error 4 error C2143: syntax error : missing ';' before '{' c:\users\evan\documents\visual studio 2012\projects\huffman\huffman\source.cpp 11 1 huffman
Error 1 error C2065: 'NodePtr' : undeclared identifier c:\users\evan\documents\visual studio 2012\projects\huffman\huffman\source.cpp 10 1 huffman
Error 6 error C2065: 'Huffmantree' : undeclared identifier c:\users\evan\documents\visual studio 2012\projects\huffman\huffman\source.cpp 42 1 huffman
Error 3 error C2059: syntax error : ')' c:\users\evan\documents\visual studio 2012\projects\huffman\huffman\source.cpp 10 1 huffman