overloading operator =??
I am trying to overload the operator = in order to allocate memory ex
1 2
|
Node ptr;
ptr = new Node;
|
But not sure how to do it with this struct part PriorityQueue::Item data;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#ifndef PQUEUE_H
#define PQUEUE_H
#include <stdlib.h> // Provides size_t
struct Node; // This will be completely defined below.
class PriorityQueue
{
public:
typedef int Item;
PriorityQueue( );
PriorityQueue(const PriorityQueue& source);
~PriorityQueue( );
void operator =(const PriorityQueue& source);
size_t size( ) const { return many_nodes; }
void insert(const Item& entry, unsigned int priority);
Item get_front( );
bool is_empty( ) const { return many_nodes == 0; }
private:
Node* head_ptr;
size_t many_nodes;
};
struct Node
{ // Node for a linked list
PriorityQueue::Item data;
unsigned int priority;
Node *link;
};
#endif
|
Topic archived. No new replies allowed.