-2

I am creating a text compression using huffman algorithm . In this I want to create a Huffman Tree , CreateHMNode accept two nodes and create a node with sum of frequency of others .

but it shows this error ,please help me to solve

LNK2019 unresolved external symbol "public: __cdecl HMnode::HMnode(void)" (??0HMnode@@QEAA@XZ) referenced in function "public: void __cdecl HMtree::build_tree(class HMnode *,class HMnode *)" (?build_tree@HMtree@@QEAAXPEAVHMnode@@0@Z)

void  build_tree(HMnode* temp3, HMnode* temp13)
{

    HMnode* head1;

    HMnode* newnode = new HMnode;
    newnode = createHMNode(temp3, temp13);
    head1 = newnode;
    HMnode* mytemp = calldeque();
    createHMNode(newnode, mytemp);

}
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621

1 Answers1

0

The HMnode::HMnode(void) mentioned in the error message is the HMnode default constructor.

When you do new HMnode you default-construct a HMnode object, and it needs the default constructor.

If, for some reason, you don't have a default constructor you will get an error about it. Normally you would get a compiler (not link) error, which means there's a declaration of the HMnode default constructor, but there's no definition (implementation).

Either you don't link with all object files or libraries, or you forgot to define (implement) the default constructor in your code.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • Thankyou soo much it is solved . error is in default constructor {} are missing that's why this error is coming ,bundle of thanks – Rehan Akhtar Dec 18 '22 at 07:06
  • @RehanAkhtar If you don't have any code or other specific initialization in your default constructor, mark it as "defaulted", like `HMnode() = default;` Then the compiler will create a suitable constructor for you. – Some programmer dude Dec 18 '22 at 07:08