c++ - 不是我要内容的地址?

标签 c++ oop

我只是因为在我的代码上浪费了更多时间而变得越来越困惑。我只想要迭代器的内容,而不是它的地址。这是我的代码:

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)); 

关于c++ - 不是我要内容的地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16530211/

相关文章:

c++ - 动态改变类的模板参数

c++ - 如何从boost的gzip_decompressor()获取gzip_params

c++ - sql::SQLString 行为

python - Python 中带有额外参数的父方法

PHP 面向对象 : Use string as identifier for an alias

C++14 值初始化问题

c++ - 嵌套类中的可变参数模板

c++ - 如何在 C++ 中为这种父子层次结构建模?

oop - 不可变集合是值对象吗?

r - 引用类的有效性方法