简体   繁体   中英

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

In your header add this:

class HuffmanTree {

public:
      ~HuffmanTree(void);

In your .cpp file:

HuffmanTree::~HuffmanTree(void) {
   ;
}

Adding 'void' worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM