tan@duke.cs.duke.edu (Jit Keong Tan) (02/08/91)
Subject: How to link pointers together during constructor declaration ? Is is possible to do the following: ===================================================== class linked_list { static int first=1; static linked_list *head; public: linked_list *next; linked_list() { if (first == 1) { first=0; next=NULL; head = ???? the declaration of the first element how to get the address ? } else { find the end of the list and link the current variable. how to get it ? } } }; During declaration, linked_list aa,bb; will automatically initialize aa.next = bb; bb.next = NULL; and sometime later in the code, linked_list *cc= new linked_list; will make it to aa.next = bb; bb.next = cc; cc->next = NULL; is it legal to do something like linked_list::linked_list(linked_list *aa) { head=aa; } linked_list aa(&aa); ? ===================================================== Please keep in mind that I am just starting C++ programming. So any suggestion, including a totally different way of implementing it (automatically) is very much appreciated. Thanks. -- ======================= internet: jit@slic.cellbio.duke.edu