首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不是我想要内容的地址?

不是我想要内容的地址?
EN

Stack Overflow用户
提问于 2013-05-14 04:03:50
回答 2查看 73关注 0票数 1

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

代码语言:javascript
复制
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
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-05-14 04:18:52

尝试将您的代码更改为以下代码:

代码语言:javascript
复制
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)); 
票数 2
EN

Stack Overflow用户

发布于 2013-05-14 04:05:44

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

迭代器重载*运算符并返回数据。(感谢更正,我不知道这一点!)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16530211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档