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 6 4836
"newtothis" <me*********@db forums.com> wrote in message
news:35******** ********@dbforu ms.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
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
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
In article <35************ ****@dbforums.c om>,
newtothis <me*********@db forums.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
newtothis <me*********@db forums.com> wrote in message
news:35******** ********@dbforu ms.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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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' => 'aaa')
, array( 'id' => 'B', 'parent_id' => 'A', 'value' => 'bbb')
, array( 'id' => 'C', 'parent_id' => 'B', 'value' => 'ccc')
, array( 'id' => 'D', 'parent_id' => 'A', 'value' => 'ddd')
|
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. And i have
things to offer, and to request.
And a lot of ideas, but who needs them....
here's an example (from type_struct.py):
|
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:
|
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 LOCATE subroutine that
returns a node????
Any help would be appreciated.
Thanks
|
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 hits the right
and left keys to move this insertion point (cursor)
Here is the problem:
| |
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 potential pitfalls I'd be extremely
grateful.
Cheers
Steve
|
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 and list2, each
node within list1 has various data and needs to have a pointer to the
corresponding node in list2, but I cant figure out how to do this.
Could someone explain what I might be missing, or maybe point me in the
direction of a good...
|
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 properly formatted. I'll post
my code below. Thanks in advance.
This is the code for the linked list. It tests using int's and string's.
#ifndef LIST_H
#define LIST_H
|
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 list. So on the list I can go Trevor, Kevin, Allan in a straight row but I can also call out there last name when I am on their first name in the list. Sorry if it doesn't make sense trying to explain best I can.
So far I have
// list.cpp
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |