CString showW,showM;
std::list<CString>::iterator it ;
for(it = findf.fils.begin();it != findf.fils.end();++it){
wcont++;
showW += *it;
showW += "\r\n";
}这段代码中,findf是一个类的对象,fils是这个类的成员变量,std::list<CString> fils;
这里的it只是一个变量,而不是一个指针变量,为什么下面循环中,感觉it像一个数组指针?
希望大家给小弟讲解一下!
简单说说把,就是可以指向容器中元素的东西,就好像指针那样,但是它不是指针。
他提供一种方法顺序访问一个聚合对象中各个元素,而又不需要暴露对象的内部表示。
具体参看C++ Primer的讲解
在Vector容器中也用迭代器。
//将用户处理后的联动对象添加到“联动设置”对话框的列表中
int rowNum = m_lstCmbMotion.GetItemCount();
std::vector<AlertRecTarget>::iterator pIterAlertRec;
for (pIterAlertRec=recordMTargetSelectdlg.m_alertRecTargets.begin();
pIterAlertRec!=recordMTargetSelectdlg.m_alertRecTargets.end();
pIterAlertRec++)
{
str.LoadString(IDS_CMBMOTIONTYPE_ALERTREC);
m_lstCmbMotion.InsertItem(rowNum,str);
m_lstCmbMotion.SetItemText(rowNum,1,pIterAlertRec->DevName.c_str());
m_lstCmbMotion.SetItemText(rowNum,2,pIterAlertRec->DevIp.c_str());
m_lstCmbMotion.SetItemText(rowNum,3,pIterAlertRec->ChannelName.c_str());
m_lstCmbMotion.SetItemText(rowNum,4,pIterAlertRec->ChannelGuid.c_str());
rowNum++;
}
std::vector<AlertRecTarget> m_alertRecTargets;