Thread: Problem with vector iterator

  1. #31
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    No problems, Programmer_P. I am going to exercise the option of placing you on my ignore list, so I will not see your replies or any further posts.

    You got help because you got lucky, not because of any good aspects of your approach in the forum.

    You did not make effort to find the actual problem, since you assumed it was in a particular place. If you had actually put in effort to remove code, to make a smaller example that compiles, links, and exhibits your problem, you would probably have found it yourself.

    By removing code unrelated to your problem, I am not suggesting all you needed to do was post the one line where you thought the problem is. I am advocating a problem solving approach that is more robust than "I think the problem is here, but here's the rest of my mess for you to sift through while I go and look at other things". If you had removed (or commented out) some lines, recompiled, run again you would have been able to narrow down on the actual cause. And, if you had done that and still not understood why the problem was occurring, other people would have had a more tractable problem to address.

    This forum exists to help people with problems, true. But the art of asking for help in forums is that you contribute to solving your own problem, through effort to narrow things down, through investigations in which you might find the problem yourself. Not just being lazy, giving up when things aren't immediately obvious, and expecting others to sort through your mess.

    That is where your logic is faulty. People contribute to forums to help people who help themselves, but get in trouble. They do not participate to help people who expect others to do the hard yards that they should do.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  2. #32
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Programmer_P
    And yet, if I had done what you seem to think I hadn't, and "removed aspects unrelated to my problem", no one would have been able to discover the real cause of the problem, now would they have?
    Seeing as the real problem was to be found in struct 'S_browser'...not in the code that was producing the symptoms of the problem (i.e. in int main() ).
    I like to request that people come up with the smallest and simplest (compilable) program that demonstrates the problem because it makes it easier for help to be given. This was inspired by an interview of Stroustrup in 2000:
    Quote Originally Posted by Bjarne Stroustrup
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exibit the problem and send me that. Mostly, they then find the error themselves. "finding the smallest program that demonstrates the error" is a powerful debugging tool.
    In other words, besides making it easier for help to be given to you, it also makes it easier for you to help yourself. Consider: if you remove that code, then you don't have a problem. Hence, you have an inkling that the problem lies in the code that you removed when trying to simplify. This is a tool that you can take with you no matter how skilled you become because there is always something that you do not know about programming.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #33
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by grumpy View Post
    No problems, Programmer_P. I am going to exercise the option of placing you on my ignore list, so I will not see your replies or any further posts.

    You got help because you got lucky, not because of any good aspects of your approach in the forum.

    You did not make effort to find the actual problem, since you assumed it was in a particular place. If you had actually put in effort to remove code, to make a smaller example that compiles, links, and exhibits your problem, you would probably have found it yourself.
    Right. Ok, you read my mind...I assumed it was in a particular place. However, I'm reading your mind now, and saying I did NOT assume that it was in the same place as where the problem first appeared, as you believe. YOU assumed I assumed. It is because of posters like you that I actually worded my posts the way that I did to start with, because I have had experiences with poster named 'grumpy' before (aptly named too...). I figured you would react the way that you reacted, and assume I didn't go to any effort to fix my problem. And how dare you say I didn't go to any effort...as if you're seeing through my eyes, and thinking with my mind. You're in no place to judge, my friend...honestly, you have no way of knowing for sure what the truth is in another person's life. You can only speculate and conjecture, going from some words someone has spouted forth. As a matter of fact, I DID go to more effort than you think I did. I didn't just look in the original place of the problem. I looked elsewhere too. But still I did not spot the problem, because I didn't know the right place to look.

    By removing code unrelated to your problem, I am not suggesting all you needed to do was post the one line where you thought the problem is. I am advocating a problem solving approach that is more robust than "I think the problem is here, but here's the rest of my mess for you to sift through while I go and look at other things". If you had removed (or commented out) some lines, recompiled, run again you would have been able to narrow down on the actual cause. And, if you had done that and still not understood why the problem was occurring, other people would have had a more tractable problem to address.
    Ohh...right. And I didn't do that??? Again, this is only your conjecture talking. The real truth of the matter is, I...and I will emphasize this....DID...COMMENT OUT LINES AND RECOMPILED and RUN AGAIN...etc. Do you really think I did not think to do that, or was simply too lazy to do that? That is some bull........, man, because that is not so. I did do all that, but still was not able to locate the real cause of the problem. I knew it was related to attempting to add elements to the vector inside of the map, but all the references I looked at on segfaults showed things like doing things with pointers to objects that don't exist anymore, or attempting to dereference a pointer that was previously deleted, etc. All of the things it said could be the cause, I looked for in my code, but still did not spot it. But that was because I didn't know how the internals of the std::map worked. But now I know a little more about it, thanks to kdmv.

    This forum exists to help people with problems, true. But the art of asking for help in forums is that you contribute to solving your own problem, through effort to narrow things down, through investigations in which you might find the problem yourself. Not just being lazy, giving up when things aren't immediately obvious, and expecting others to sort through your mess.
    Again, this is something you think I did not do, but I did. But I see there's no point in trying to convince you that I did...you're stuck on that same mindset that everyone who asks help for a problem should have gone to incredible amounts of effort to fix the problem themselves before even thinking to ask for help or advice.

    That is where your logic is faulty. People contribute to forums to help people who help themselves, but get in trouble. They do not participate to help people who expect others to do the hard yards that they should do.
    Yeah...keep telling yourself that one. And maybe one of these centuries, someone will actually believe it.
    And as if I was actually thinking like that...

    Man, you don't even know WHAT I'm thinking right now. And I don't know what you're thinking right now...nor do I want to know.

    I rest my case.
    Last edited by Programmer_P; 01-07-2013 at 11:03 PM.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  4. #34
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by laserlight View Post
    I like to request that people come up with the smallest and simplest (compilable) program that demonstrates the problem because it makes it easier for help to be given. This was inspired by an interview of Stroustrup in 2000:
    You are right, but only to an extent. I think people have taken the whole concept of "the smallest and simplest program" a little too far...and now basically want those who ask for help to do unrealistic things, and make the code only a few lines in length, even when one is trying to do somewhat more complicated operations than simply outputting a string...

    In other words, besides making it easier for help to be given to you, it also makes it easier for you to help yourself. Consider: if you remove that code, then you don't have a problem. Hence, you have an inkling that the problem lies in the code that you removed when trying to simplify. This is a tool that you can take with you no matter how skilled you become because there is always something that you do not know about programming.
    Yes, and that is what basically led to this thread.

    Progression of events:

    1. I wrote code.
    2. My code compiled and ran, but then "ended unexpectedly".
    3. I immediately went to the debugger, and ran it again, and this time discovered that the reason it ended prematurely when I ran it normally, was because of a segfault.
    4. I googled "segmentation fault" or something to that effect, and looked at the results, and read other people's problems with segfaults, and explanations of why they occur.
    5. I then looked at my code for any use of any of the things that might produce segfaults. I found none.
    6. Several days...and weeks...went by. Each day (ok...maybe that's an exaggeration; some days...), I re-examined my code, commented out lines, rebuilt it and rebuilt it, etc...and looked at information online about segfaults and other things I thought might be the problem causing the segfault, and tried to find out what was causing the problem, but wasn't able to locate the real source of the problem.
    7. So I tried to reproduce the problem on codepad.org, using simplified code, and narrowed it down to what I posted in this thread to start with.
    8. Then, I created this thread....
    Last edited by Programmer_P; 01-07-2013 at 11:29 PM.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  5. #35
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    And maybe one of these centuries, someone will actually believe it.
    O_o

    You don't deserve even a second of the time these folks have spent helping you.

    I invite you, Programmer_P, to observe that you are the one factor in common to all of your threads, most of which follows this exact same progression.

    Once again, you've gotten luck in finding help despite how poorly you behave and present your problem.

    I really hope people remember you this time.

    Soma

  6. #36
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by phantomotap View Post
    O_o

    You don't deserve even a second of the time these folks have spent helping you.

    I invite you, Programmer_P, to observe that you are the one factor in common to all of your threads, most of which follows this exact same progression.

    Once again, you've gotten luck in finding help despite how poorly you behave and present your problem.

    I really hope people remember you this time.

    Soma
    Yeah...?

    Well, I wasn't born perfect. But I guess you think you were.
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  7. #37
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Some are born perfect, some achieve perfection, and some have perfection thrust upon them.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #38
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by laserlight View Post
    Some are born perfect, some achieve perfection, and some have perfection thrust upon them.
    Hahaha...and you know this HOW??

    Judging from what I've seen of other people all the time, I really don't think that's the case at all...
    I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.

  9. #39
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by laserlight View Post
    Some are born perfect, some achieve perfection, and some have perfection thrust upon them.
    Maybe on the 12th night.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  10. #40
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    This thread is clearly not useful anymore.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem using a vector iterator in a loop.
    By M.Richard Tober in forum C++ Programming
    Replies: 6
    Last Post: 10-29-2011, 01:53 PM
  2. vector and iterator problem
    By BeBu in forum C++ Programming
    Replies: 10
    Last Post: 03-11-2009, 07:38 AM
  3. Vector Iterator Help
    By (TNT) in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2007, 02:53 PM
  4. vector<object>::iterator Help
    By The Brain in forum C++ Programming
    Replies: 16
    Last Post: 03-26-2006, 07:22 PM
  5. Iterator _ erasing from a vector help
    By Hexxx in forum C++ Programming
    Replies: 1
    Last Post: 03-22-2006, 07:43 PM