Christian Olson
Christian Olson

Reputation: 51

definition of implicitly-declared destructor

in my header file for my HuffmanTree binary tree class I have the declaration of my destructor:

//huffman.h
using namespace std;

#ifndef HuffmanTree_H
#define HuffmanTree_H
class HuffmanTree
{
        public:
        ~HuffmanTree();
};
#endif

and in my cpp file I have the implementation of my destructor

//huffman.cpp

#include "huffman.h"

using namespace std;

//destructor
HuffmanTree::~HuffmanTree()
{

}

note: I have not finished writing the destructor body because I want it to compile

the exact text of the error is:

huffman.cpp:8:27: error: definition of implicitly-declared ‘HuffmanTree::~HuffmanTree()’
    HuffmanTree::~HuffmanTree()
                              ^

thank you for any help you can give

Upvotes: 2

Views: 6746

Answers (1)

Keith
Keith

Reputation: 59

In your header add this:

class HuffmanTree {

public:
      ~HuffmanTree(void);

In your .cpp file:

HuffmanTree::~HuffmanTree(void) {
   ;
}

Adding 'void' worked for me.

Upvotes: 0

Related Questions