Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class doublyLinkedList
- {
- protected:
- double_node *head, *tail;
- int length;
- public:
- ///constructor
- doublyLinkedList()
- {
- this->head = NULL;
- this->tail = NULL;
- this->length = 0;
- }
- doublyLinkedList(double_node *head, double_node* tail, int length)
- {
- this->head = new double_node;
- this->tail = new double_node;
- this->head = head;
- this->tail = tail;
- this->length = length;
- }
- ///destructor
- ~doublyLinkedList()
- {
- double_node *current = head;
- while ( current != tail ){
- double_node* next = current->get_next();
- delete current;
- current = next;
- }
- delete tail;
- }
- ///operator=
- doublyLinkedList operator=(doublyLinkedList& lista)
- {
- double_node* nod1 = lista.head;
- double_node* nod2 = head;
- cout<<"0";
- ///tentativa mea
- if(lista.head != NULL)
- {
- cout<<"1";
- this->head = lista.head;
- cout<<"2";
- double_node* nod1 = lista.head;
- cout<<"3";
- double_node* nod2 = head;
- cout<<"4";
- while(nod2 != lista.tail)
- {
- cout<<"5";
- nod1 = (double_node*) nod1->get_next();
- cout<<"6";
- nod2 = (double_node*) nod2->get_next();
- cout<<"7";
- }
- tail = lista.tail;
- length = lista.length;
- this->length = lista.length;
- }
- return (*this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement