通过浪费更多时间在我的代码上,我越来越困惑。我只想要迭代器的内容,而不是它的地址。这里是我的代码:不是我想要的内容的地址?
Peptides tempPep;
tempPep.set_PEPTIDE("AABF");
std::vector<Peptides>::iterator itPep = std::find_if (this->get_PepList().begin(), this->get_PepList().end(),boost::bind(&Peptides::Peptide_comparison, _1,tempPep));
if (itPep != this->get_PepList().end())
{
Spectra tempSp;
tempSp.set_Charge(1127);
tempSp.set_Snum(1);
std::cout << "without iterator "<< this->get_PepList()[0].get_New_S_num() << std::endl;
// output -> 0
std::cout << "with iterator" << itPep->get_New_S_num() <<std::endl;
//output -> 1129859637
}
是什么'get_PepList()'返回副本或引用?当呼叫返回的向量已过期时,itPep可能是悬而未决的。 – 2013-05-13 20:11:32
在C++类型是至关重要的。什么是Peptides,什么是这个''的类型以及'get_PepList()'和'get_New_S_num()'是如何工作的。 – 2013-05-13 20:17:01