CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    2

    First chance exception:crash

    list<Pnt*>::iterator start =hex_cplist_combine->PntList_xy.begin();
    list<Pnt *>::iterator end ;


    for(start; start !=hex_cplist_combine->PntList_xy.end()
    {
    //FreePntArr();
    g_ObjRecSetup.mappingsetup.CartStarter.x = (*start)->x;
    g_ObjRecSetup.mappingsetup.CartStarter.y = (*start)->y;

    end=hex_cplist_combine->PntList_xy.begin();
    //for(end; end !=cart_cplist->PntList_xy.end()
    for(end; end !=hex_cplist_combine->PntList_xy.end()
    {


    Curve * pPolarPath, * pCartPath;
    pPolarPath = newCurve();
    pCartPath = newCurve();
    try
    {

    g_ObjRecSetup.mappingsetup.CartEnd.x= (*end)->x;
    g_ObjRecSetup.mappingsetup.CartEnd.y = (*end)->y;
    }
    catch (exception& e)
    {

    AddReportData(0,"exception caught:%s",e.what());
    }
    display();

    end++;
    }
    start++;
    }

    Above is the part of my code.I keep getting first chance exception at the line highlighted in bold.My code also crashes and I cant figure out why?The list does have values and nothing is null as far as I checked.
    Thanks
    Shweta

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,448

    Re: First chance exception:crash

    You can't dereference an end iterator: It points past the last item in the container. You can't increment an end iterator either, BTW.

    Unlike the original in that ancient thread, this post doesn't have any line highlighted in bold, BTW. And please use code tags when posting code. The way it is now, your code is almost absolutely unreadable.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width