-1

Error from this file heap.h. Error from redefinition of MAX_HEAP, and heapclass. I keep on getting an error that its redefinition yet, I do not see another definition. Any other reasons? The error is found here.

// *********************************************************
// 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

main

Data.cpp

Data.h

Heap.cpp

PQ.cpp

PQ.h

Thank you
Jongware
  • 22,200
  • 8
  • 54
  • 100
crod
  • 235
  • 3
  • 5
  • 12

1 Answers1

1

"#pragma once" should be used to prevent multiple inclusion of the contents of the header files. See: https://msdn.microsoft.com/en-us/library/4141z1cx.aspx?f=255&MSPPError=-2147217396

Also see: Is #pragma once a safe include guard?

Community
  • 1
  • 1
Garland
  • 911
  • 7
  • 22