簡體   English   中英

一個如何顯示多個向量的搜索結果? C ++

[英]How does one display search results for multiple vectors? C++

假設用戶在向量中搜索某個數字(vector number();),那么如何顯示該vector [i]的結果以及其他vector中的對應[i]?

請考慮為此使用迭代器

范例程式碼

for(yourVector<YOUR_OBJECT_TYPE>::iterator it = yourVector.begin(); it != yourVector.end(); it++)
    if(it == indexOfDesiredElement) {
         YOUR_OBJECT_TYPE theValue = *it;
         // pass theValue to a helper method and proceed from there.
}
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM