473,216 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

some assistance with a linked list


Being new to the use of C++ I have written a linked list program. It
seems to crash after I delete from the list and then add a new node.

Also this is not college homework, I have also looked at various
postings here on the topic. They do not seem to help.

If someone more of an expert than me could please check what I have put
together and make some relivent comment I am happy to post the files to
the program, once I work out how to attache them all.

Thanks
--
Posted via http://dbforums.com
Jul 19 '05 #1
6 4807
"newtothis" <me*********@dbforums.com> wrote in message
news:35****************@dbforums.com...

Being new to the use of C++ I have written a linked list program. It
seems to crash after I delete from the list and then add a new node.

Also this is not college homework, I have also looked at various
postings here on the topic. They do not seem to help.

If someone more of an expert than me could please check what I have put
together and make some relivent comment I am happy to post the files to
the program, once I work out how to attache them all.


Don't attach any of them. Attachments are not well received in non-binary
newsgroups. Just include the code in your post, preferably the smallest
amount of code that exhibits the problem. Write a small test program that
does nothing but operations on the list, and remove any functions that are
not executed. The smaller the code the more people will have the time to
look at it.

DW

Jul 19 '05 #2

Thanks David.

I would but the program is divided into 3 distinct classes, the list ,
the node and the datacomponent stored in the node. plus the main test
driver program. 7 seperate files

From what I can see I think my code needs some form of cleaning up. That
is where I need some assistance.

It looks as if I am getting some form of stack overflow since i am not
getting rid of old nodes, etc.

The program works if it write it in java or C. I seem to be having some
problems with this in C++.

I am trying to build an event queue, as a llinked list so I really only
want the list and node components when its finished.
--
Posted via http://dbforums.com
Jul 19 '05 #3


newtothis wrote:

Thanks David.

I would but the program is divided into 3 distinct classes, the list ,
the node and the datacomponent stored in the node. plus the main test
driver program. 7 seperate files


And ?

Your problem is a crash when adding a node after you have deleted one.
So all we need to see is the add function and the delete function.
Add a list class which contains only those 2 functions, add a node class
and a main() which calls this 2 functions in that order.
Make sure that this also crashes and ...
.... post

If you don't think you have the time to do this, then I am sorry,
nobody will have the time to wade through your code, analyze it,
figure out where you went wrong and tries to give some advice on
where your mental model is wrong and fix your bugs at the
same time.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 19 '05 #4
In article <35****************@dbforums.com>,
newtothis <me*********@dbforums.com> wrote:

Being new to the use of C++ I have written a linked list program. It
seems to crash after I delete from the list and then add a new node.

Also this is not college homework, I have also looked at various
postings here on the topic. They do not seem to help.


So is there any reason you aren't just using some of the available STL
containers: vector, list, deques, ect...?

If you are new to C++ then I recommend you use these data structures rather
than creating your own.

John
Jul 19 '05 #5
newtothis <me*********@dbforums.com> wrote in message
news:35****************@dbforums.com...

Thanks David.

I would but the program is divided into 3 distinct classes, the list ,
the node and the datacomponent stored in the node. plus the main test
driver program. 7 seperate files


It still shouldn't be too difficult to narrow it down to the problem at
hand. Just copy and paste the linked-list class definition and the add and
delete functions into a single source file. Then add a main() that creates a
list and adds and deletes nodes, and adds them again (whatever causes the
problem). Use a simple, dummy class for the data component if what you have
now is really big and complicated. It shouldn't affect the operation of the
list. Make sure this cut-down version still exhibits the problem and then
post it here. Everyone is happy to help, but few have the time to look
through pages and pages of code.

If the test program does not exhibit the problem, then as a last resort you
can try posting everything (but not in attachments). Someone might be able
to look at it.

DW

Jul 19 '05 #6

Thanks for the various comments on this. It appears the problem is a
little more complex and possible related to stack space. I have run the
program on a different computer, ie different OS but same brand of
compiler and it works fine.

It just does not like windows. Wont run using VC++ either but compiles.

Tanks anyway. still need to clean the coe up a bit
--
Posted via http://dbforums.com
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeffrey Silverman | last post by:
Hi, all. I have a linked list. I need an algorithm to create a tree structure from that list. Basically, I want to turn this: $list = array( array( 'id' => 'A', 'parent_id' => null, 'value'...
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
11
by: C++fan | last post by:
Suppose that I define the following class: class example_class{ public: example_class(); void funtion_1(); void function_2(); protected:
5
by: Dream Catcher | last post by:
1. I don't know once the node is located, how to return that node. Should I return pointer to that node or should I return the struct of that node. 2. Also how to do the fn call in main for that...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
6
by: Steve Lambert | last post by:
Hi, I've knocked up a number of small routines to create and manipulate a linked list of any structure. If anyone could take a look at this code and give me their opinion and details of any...
12
by: joshd | last post by:
Hello, Im sorry if this question has been asked before, but I did search before posting and couldnt find an answer to my problem. I have two classes each with corresponding linked lists, list1...
13
by: B. Williams | last post by:
I have written some code to accept input and place this input at the beginning or end of a list, but I need assistance including a class so that it will allow input of a phone number that is...
1
by: theeverdead | last post by:
Ok I have a file in it is a record of a persons first and last name. Format is like: Trevor Johnson Kevin Smith Allan Harris I need to read that file into program and then turn it into a linked...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.