Hello everyone, I am having a hard time figuring out how to form a circular doubly linked list from a text file. I know I have to store the data from the text file to a vector and then somehow store each vector element to the circular doubly linked list using the loop, but I am just not really sure how to do it and I cannot find any suitable example in the internet. Please help...
Here is the code I use, before doing any of these operations I want to form a circular doubly linked list with the data from the text file.
When posting code, please use code tags. Edit your post, highlight the code and then click the "<>" button to the right of the edit window. This will cause the code to appear with line numbers and syntax highlighting. It makes it much easier for us to refer to specific parts of the post.
start, last and counter should members of class double_clist. Otherwise you can't really have a program with two separate lists.
create_node() should probably be private. Some one using the list shouldn't have to worry about creating nodes.
insert_begin() should just insert a value at the beginning of the list. E.g., it should be void insert_begin(int value). All the code that prompts for the value should be part of the main program, not part of the list class. After all, when it comes to inserting the values from a file, you won't want to prompt the user for a value.
Same comment applies to the other methods.
insert_begin(): you need to set last when inserting into an empty list.
insert_last(): you need to set start when inserting into an empty list.
insert_pos(). Exactly where does it insert the item? Before pos? After pos? Is the first item considered position 0 or position 1? Either way, when inserting into non-empty list, you may need to update start and/or last.