473,407 Members | 2,315 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,407 software developers and data experts.

Cleaning up a data structure

63
Expand|Select|Wrap|Line Numbers
  1. struct node
  2. {
  3.     node(char * product):next(NULL)
  4.     {
  5.         item = new char[strlen(product)+1];
  6.         strcpy(item, product);
  7.     }
  8.     ~node()
  9.     {
  10.         delete item;
  11.         delete next;
  12.     }
  13.  
  14.     node * next;
  15.     char * item;
  16.  
  17. };
  18.  
Lets say I had a linked list with stated the node being the stated code.

When I delete a node, does that trigger the destructor? And if so, does that mean that every node behind that node in the linked list gets removed from memory since the destructor deletes the next node in the list?

Just wondering because it would be easier then going through the whole list deleting every node.
Mar 11 '07 #1
2 2642
Ganon11
3,652 Expert 2GB
delete does call the destructor, and so deleting the next pointer would create a cascade effect, deleting the entire list.

Are you sure this is what you want to do?
Mar 11 '07 #2
iLL
63
Are you sure this is what you want to do?
Well I was just thinking conceptually, but yeah. To remove just one node, I could just isolate that node, and then delete it. And in terms of a linked list, I’d do that anyway.

Oh, and thanks for the response [thumbsup]
Mar 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ellen K. | last post by:
What tools has everyone used for cleaning name and address data (including identifying not-immediately-obvious duplicates) in connection with a CRM project or the Customer dimension of a data...
3
by: Mike Jones | last post by:
need help with data structures.Looking for ways to start, sample code, anything Program description: Design and implement a Visual C++ .NET program that inserts values into a data...
2
by: yee young han | last post by:
I need a fast data structure and algorithm like below condition. (1) this data structure contain only 10,000 data entry. (2) data structure's one entry is like below typedef struct _DataEntry_...
3
by: Pierre Saint-Jacques | last post by:
DB2 V8.2 has a new envir. var. DB2_USE_ALTERNATE_PAGE_CLEANING=YES The docs. mention that this will make DB2 ignore chngpgs_thresh and use softmax to even the rate of writing out of the bp's. ...
12
by: Santosh | last post by:
Since I just started my new work, I have inherited a MS Access database which has nearly 13000 records in a single table. Now, my mandate is to clean the database and maybe split the table into...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
3
by: Kiran B. | last post by:
Hi, I am new to .net. I have two Data Structure Type ... Sturcture A and Structure B. Structure A Public Fname as String Public LastName as String Public City as String Public Zip as String...
3
by: aurora | last post by:
This is an entry I just added to ASPN. It is a somewhat novel technique I have employed quite successfully in my code. I repost it here for more explosure and discussions. ...
29
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
0
by: Now You Know | last post by:
Carpet Cleaners Los Angeles Home Carpet Rug Upholstery Cleaning Phone 1 310 925 1720 OR 1-818-386-1022 Local Call California Wide We offer carpet cleaning services such as; Steam Cleaning, Dry...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
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,...
0
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...
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
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
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.