Posted: Fri Aug 24, 2007 2:45 pm
ok, i though i had it all figured out, to me this should work without problems, but maybe youre all of another oppinion cause theres definently some trouble somewhere allthough its kinda hard to pinpoint...
Code: Select all
#include <iostream>
class T {
struct node { // well this is obious
unsigned long ID; // uniquesnode id
node *next;
node *prew;
};
node *root;
unsigned long ncount; // number of nodes
public:
T(unsigned long i) { // initializing and constructing
unsigned long id = 0;
ncount = i;
root = new node;
node *temp = root;
for(int n = 1; n < ncount; n++, id++) {
temp->ID = id;
temp->next = new node;
temp->next->prew = temp;
temp = temp->next;
}
temp->next = root; // making it circular, well i though it would
root->prew = temp;
}
void Print_List() { // a little print func that should print the whole list
while(root->ID < root->next->ID) {
std::cout << root->ID << std::endl;
root = root->next;
}
}
};