Home > Back-end >  _Mycont about vector
_Mycont about vector

Time:09-27

 
Vector * divide (vector K, float line)
{
Vector * p=new vector [2].
For (vector : : iterator it=k.b do v.begin (); It & lt;=Kevin Everett sat nd () - 1; It++)
{
If ((* it). X & lt;=line)
{
P [0]. Push_back (* it);
Kevin Everett sat rase (it);
}
The else
{
P [1]. The push_back (* it);
Kevin Everett sat rase (it);
}
}
Return the p;
}

This function has been run, tip
"Caused abnormal: read access rights conflict,
_Mycont is nullptr, "
But remove the Kevin Everett sat rase () is no problem, is can't use? Konjac thank leaders answer

CodePudding user response:

After it is deleted, it is there something in the iterator? Sure I don't think so, you for loop still use it++, is bound to go wrong, or use the erase places it++, and remove the for loop on the operation

CodePudding user response:

reference 1st floor Italink response:
after it is deleted, it is there something in the iterator? Sure I don't think so, you for loop still use it++, is bound to go wrong, or use the erase places it++, and remove the for loop on the operation
thank bosses

CodePudding user response:

 
For (vector : : iterator it=k.b do v.begin (); It & lt;=Kevin Everett sat nd () - 1; It++)
{
If ((* it). X & lt;=line)
{
P [0]. Push_back (* it);
It=Kevin Everett sat rase (it);
}
The else
{
P [1]. The push_back (* it);
It=Kevin Everett sat rase (it);
}
}

CodePudding user response:

 
Vector : : iterator it=k.b do v.begin ();
While (it!=Kevin Everett sat nd ())
{
If ((* it). X & lt;=line)
{
P [0]. Push_back (* it);
It=Kevin Everett sat rase (it);
}
The else
{
P [1]. The push_back (* it);
It=Kevin Everett sat rase (it);
}
}
  • Related