-2

I have the default constructor but the copy constructor I am having trouble with. Any help.

enum Direction { front_to_back, back_to_front };

template <typename EType>
class Queue
{
  private:

    struct Node
    {
      EType Item;
      unsigned Priority;
      unsigned Identifier;
      Node * Pred;
      Node * Succ;
    };

    Node * Head;    // Pointer to head of chain (front)
    Node * Tail;    // Pointer to tail of chain (back)

  public:

    // Initialize pqueue to empty
    //
    Queue();

    // De-initialize pqueue
    //
    ~Queue();

    // Re-initialize pqueue to empty
    //
    void reset();

    // Initialize pqueue using existing pqueue
RohitWagh
  • 1,999
  • 3
  • 22
  • 43

1 Answers1

2

Since you are playing with raw pointers here you want to disable copy construction and assignment to avoid double-delete problems and memory leaks. This could be done either via:

private: // note that these are not implemented

    Queue( const Queue& );
    Queue& operator=( const Queue& );

or via inheriting from boost::noncopyable.

Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171