Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Welcome to the TechnoWorldInc! Community!
Recent Updates
[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » C/C++/C#
 C/C++ Doubly Linked List
Pages: [1]   Go Down
  Print  
Author Topic: C/C++ Doubly Linked List  (Read 3421 times)
Taruna
Elite Member
*****



Karma: 13
Offline Offline

Posts: 845

Hi ALL


View Profile
C/C++ Doubly Linked List
« Posted: December 27, 2006, 12:37:27 AM »


The implementation of a doubly linked list, remove prev pointer for a singly linked list

Code:
struct Node{ 
public:
   Member*      info; //type is arbitrary, to the linked list implementation
   Node*      next; //used to point to next node
        Node*           prev; //used to point to previous node

   Node():prev(NULL),next(NULL) {} //default constructor
        Node(Node* n):prev(n),next(NULL) {} //prev known constructor
        Node(Node* n, Node* m):prev(n),next(m) {} //prev and next known constructor
   ~Node() { delete info; delete next; } //destructor
};

this list would be held by a pointer:

Code:
Node* head; 
head = &(new Node(&head);//create Node which knows prev(head) and next is NULL

then each node is attatched with a similar fasion.

To search such a list use a while loop:

Code:
Node* n = head; 
while(n->next){
//loop code
n = n->next;
}

Questions/Comments: [email protected]

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.076 seconds with 24 queries.