I'm working on a project that involves Huffman Trees. I have split my files into headers etc.
I have declared a method for allocating tree nodes in the HuffmanTree.h header file, and I am implementing it in the HuffmanTree.cpp file.
I am still getting an unresolved external, however.
Inside the header:
private:
HuffTreeNode* root;
int weight = -1; // in-class initialization of the data members
friend ostream& operator<<(ostream& out, const HuffmanTree& tree);
friend class Comparator;
bool onlyLeaf(HuffTreeNode* root);
void encode(HuffTreeNode* root, string str, unordered_map<char, string>& huffMap);
void decode(HuffTreeNode* root, int& i, std::string str);
HuffTreeNode* allocateNode(char letter, int charFreq, HuffTreeNode* left, HuffTreeNode* right);
Inside the .cpp:
// Allocating the new node to the Huffman Tree
HuffTreeNode* HuffmanTree::allocateNode(char letter, int charFreq, HuffTreeNode* left, HuffTreeNode* right)
{
HuffTreeNode* node = new HuffTreeNode();
node->myChar = letter;
node->myFrequency = charFreq;
node->myLeft = left;
node->myRight = right;
return node;
}
The error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall HuffTreeNode::HuffTreeNode(void)" (??0HuffTreeNode@@QAE@XZ) referenced in function "private: class HuffTreeNode * __thiscall HuffmanTree::allocateNode(char,int,class HuffTreeNode *,class HuffTreeNode *)" (?allocateNode@HuffmanTree@@AAEPAVHuffTreeNode@@DHPAV2@0@Z) CA2 C:\Users\me\source\repos\proj\HuffmanTree.obj 1
Any help would be appreciated.