473,406 Members | 2,217 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,406 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 4816
"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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.