Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:57:52+00:00 2026-06-06T19:57:52+00:00

I have an error in map iterators. The problem is the following: class JacobianCol

  • 0

I have an error in map iterators. The problem is the following:

class JacobianCol
{
private:
...
    JacobianColData::iterator _L_begin;
public:
    JacobianColData::iterator L_begin();
...
};

In another module:

JacobianCol LUSolver::col_subtract(const JacobianColData::iterator &alpha, JacobianCol &X, JacobianCol &Y)
{
    JacobianCol result = Y;

    //alternate "result" variable

    return result;
}

Call:

...
J[*it] = col_subtract(friend_element, J[diag_index], J[*it]);
...

And when I assign result of col_subtract to J[*it] I get J[*it].L_begin pointing to a deallocated memory (pointer to a previous J[*it]).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:57:53+00:00Added an answer on June 6, 2026 at 7:57 pm

    JacobianCol has the _col_data member. i.e, the input instance JacobianCol Y has a _col_data instance and _L_Begin of this is initialized with that map’s iterator. When you return the result, a different _col_data member is created. Now, the _L_Begin iterator is copied from the original Y instance. That is why you get the observed behavior.

    To resolve this implement the copy constructor, copy the map and the re-initialize the iterator by explicitly calling _col_data.begin() in the copy constructor

    JacobianCol(const JacobianCol& aSrc_in)
    {
        _coll_data = aSrc_in._coll_data;
        _L_Begin = _coll_data.begin();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: #include <map> #include <string> class policy1 { public: struct
I have the following cyclic dependency problem I am trying to solve: typedef std::map<int,
I have a template class with a private map member template <typename T> class
can inner_product not be applied to a map. I have the following code: std::map<class
I experience strange problem. We have error handling in global.asax that would redirect user
I have an std::map , and I would like to define an iterator that
I have an issue with returning an iterator from an STL map using an
I have a set of pointers to objects of the following class: class name_id
I Have following in my struts.xml file <action name=ProductVerification class=com.frontend.ProductVerification> <result name=success>/jsp/product_verification.jsp</result> <result name=input>/jsp/product_verification.jsp</result>
I have two HashMaps and I can iterate both hashmaps with following code Iterator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.