-3

Error 3 error C2011 : 'Queue' : 'class' type redefinition.

Error 2 error C2011 : 'Edge' : 'class' type redefinition.

Why this error? I compiled the program and it crashed...

    #include "Edge.h"
    class Queue
    {
    private:
        Edge * Heap;
        int hpos;
    public:

        Queue(int n);
        ~Queue();
        Edge front();
        void push(Edge e);
        void pop();

    };       
    class Edge
    {
        int v1, v2, weight;               // Wierzchołki krawędzi, waga krawędzi
    };

    #include "Queue.h"

    struct TNode
    {
        TNode * next;
        int v, weight;
    };

    class MSTree
    {
    private:
        TNode ** A;                   // Tablica list sąsiedztwa
        int Alen;                     // Liczba komórek w tablicy
        int weight;                   // Waga całego drzewa
    public:
        MSTree(int n);
        ~MSTree();
        void addEdge(Edge e);
        void print();
    };

    #include "Queue.h"


    struct DSNode
    {
        int up, rank;
    };

    class DSStruct
    {
    private:
        DSNode * Z;
    public:
        DSStruct(int n);
        ~DSStruct();
        void MakeSet(int v);
        int FindSet(int v);
        void UnionSets(Edge e);
    };
Damien
  • 1,161
  • 2
  • 19
  • 31
pcpiotrek
  • 3
  • 2

1 Answers1

1

Most probably you are getting this error because your header file included more than once from the same compilation units. You should use include guards in your headers as explained here http://en.wikipedia.org/wiki/Include_guard

Slava
  • 43,454
  • 1
  • 47
  • 90