?
Solved

problem with delete

Posted on 2003-02-21
4
Medium Priority
?
164 Views
Last Modified: 2010-04-17
hi guys,

i don't know what this error comes from.
i have created some object with new. Lets say 10 and now when i start deleting them their is a very strage thing.
when i delete the 3th object the 7th gets deleted too. And then when i want to delete the 7th i get an exeption because it's
allready gone.
If anybody knows what it is please help me.
0
Comment
Question by:kkmilan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:JoaTex
ID: 7994204
Hi
See the identification of the object.
Case if it is an array see if it doesn't have the same index.
Jo
0
 
LVL 1

Accepted Solution

by:
Gula earned 195 total points
ID: 7994343
have you copied 3rd object to 7th, or 7th to 3rd, or have you created them similar way like you tried to put same data into them from some other objects or variables..
I mean maybe you shallow copied two objects, like some part of them is pointing to the same thing, so when you delete one of them, that "thing" they both are pointing to gets deleted, and when you are trying to delete second, it is not there anymore, that's why you are getting error
0
 

Author Comment

by:kkmilan
ID: 7994730
no i didn't copied the object. But i've found my mistake.
The object has a pointer to itselfs structure and the 3th element points to the 7th element. Now when i delete the 3th objects it deletes the 7th too. The question now is how can i avoid deleting the 7th element when i still want the 3th element deleted.
thanks anyway for your anwers.
0
 

Author Comment

by:kkmilan
ID: 7997461
erm i've got another question. When i've got a program witch just creates 100000 pointer on an int. I store them in the std::list<int*>
when i have a look at the windows task manager it shows me the  memory-size my small program uses, right?!

ok now i delete every created int but the task manager seem not to decrese the memory-size. why is that?



0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Make the most of your online learning experience.
Simple Linear Regression
Six Sigma Control Plans

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question