地址不是我想要的内容

Not the address I want content?

本文关键字:我想要 地址      更新时间:2023-10-16

我只是越来越困惑,浪费更多的时间在我的代码。我只想要迭代器的内容,而不是它的地址。下面是我的代码:

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
}

尝试将代码更改为以下内容:

std::vector<Peptides> p = this->get_PepList();
std::vector<Peptides>::iterator itPep = std::find_if (p.begin(),
    p.end(),boost::bind(&Peptides::Peptide_comparison, _1,tempPep)); 

如果你想要的内容,指向它:*itPep

迭代器重载*操作符并返回数据。(谢谢你的更正,我不知道!)