Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 为什么会出现重新定义错误c++;?_C++_Compiler Errors - Fatal编程技术网

C++ 为什么会出现重新定义错误c++;?

C++ 为什么会出现重新定义错误c++;?,c++,compiler-errors,C++,Compiler Errors,此文件中的错误heap.h。重新定义最大堆和heapclass时出错。 我不断得到一个错误,它的重新定义,但我没有看到另一个定义。还有其他原因吗? 在这里可以找到错误 // ********************************************************* // Header file Heap.h for the ADT heap. // ********************************************************* #in

此文件中的错误
heap.h
。重新定义最大堆和
heapclass
时出错。 我不断得到一个错误,它的重新定义,但我没有看到另一个定义。还有其他原因吗? 在这里可以找到错误

// *********************************************************
// Header file Heap.h for the ADT heap.
// *********************************************************

#include "Data.h"  // definition of itemClass

const int MAX_HEAP = 20;
typedef itemClass keyType;

typedef itemClass heapItemType;

class heapClass
{
public:
    heapClass();  // default constructor
    // copy constructor and destructor are
    // supplied by the compiler

    // heap operations:
    virtual bool HeapIsEmpty() const;
    // Determines whether a heap is empty.
    // Precondition: None.
    // Postcondition: Returns true if the heap is empty;
    // otherwise returns false.

    virtual void HeapInsert(const heapItemType& NewItem,
                            bool& Success);
    // Inserts an item into a heap.
    // Precondition: NewItem is the item to be inserted.
    // Postcondition: If the heap was not full, NewItem is
    // in its proper position and Success is true;
    // otherwise Success is false.

    virtual void HeapDelete(heapItemType& RootItem,
                            bool& Success);
    // Retrieves and deletes the item in the root of a heap.
    // This item has the largest search key in the heap.
    // Precondition: None.
    // Postcondition: If the heap was not empty, RootItem
    // is the retrieved item, the item is deleted from the
    // heap, and Success is true. However, if the heap was
    // empty, removal is impossible and Success is false.

protected:
    void RebuildHeap(int Root);
    // Converts the semiheap rooted at index Root
    // into a heap.

private:
    heapItemType Items[MAX_HEAP];  // array of heap items
    int          Size;             // number of heap items
};  // end class
// End of header file.


here are the other files included
main contains main

应使用“
#pragma once
”来防止头文件的内容被多次包含。 见:

另见:

我怀疑您多次包含此文件,因为您没有包含防护。PQ.h包含“Heap.h”。Heap.cpp包括“Heap.h”。MAX_HEAP定义为两个“#pragma”是特定于编译器的扩展。
Thank you