Hey there I have this doubly linked class I need help with t

 Hey there I have this doubly linked class, I need help with this copy constructor.   
 Here is the Node class:    
 class Node { private:     T data;     Node<T> *prev;     Node<T> *next; 
 public:   
 template<class T> Node<T> *Node<T>::getPrev() const { return prev; }  template<class T> Node<T> *Node<T>::getNext() const { return next; } 
  --------------------------------- Here is the header file:    
 template<class T> class DLinkedStack : public StackInterface<T> { 
 private:     Node<T> *headPtr;    // Pointer to first node in the chain;     Node<T> *topPtr;     // to the end  
 template<class T> DLinkedStack<T>::DLinkedStack(const DLinkedStack<T> &aStack) {     //TODO - Implement the copy constructor  } 

Solution

Here you need to assign memory individually otherwise pointer will point to same momory location.

============================

Thanks

 Hey there I have this doubly linked class, I need help with this copy constructor. Here is the Node class: class Node { private: T data; Node<T> *prev; N

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site