c++ - Unexpected changes in std::vector -


here code:

typedef struct triplet {     double value;     int row;     int column; };  class matrix { public: //some methods double specialmethod(/*params*/); private:     std::vector<triplet> elements;     int nrows;     int ncolumns; }; 

after specialmethod gets called values in matrix.element corrupted. there nothing done them except iterating this:

std::vector<triplet>::iterator it; std::vector<pair> buff; (it = this->elements.begin(); != this->elements.end(); ++it)     {          if (it->column = n)         {              pair p;             p.key = it->row;             p.value = it->value;             buff.push_back(p);         }     } 

don't have idea start looking mistake.

  if (it->column = n) 

should be:

 if (it->column == n) 

you doing comparison not assignment.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -