zoukankan      html  css  js  c++  java
  • Dereference and Increment on vector Iterators

    Dereference and Increment on vector Iterators

    • The operations on iterator types let us retrieve element to which an iterator refers and let us move an iterator from one element to another.

    • Iterator types use the dereference operator (the * operator) to access the element to which the iterator refers:

    *iter=0;	//The effect of this statement is to assign 0 to that element
    
    • The dereference operator returns the element that the iterator currently denotes.Assuming iter refers to the first element of the vector,then *iter is the same element as ivec[0].The effect of this statement is to assign 0 to that element.

    A Program that Uses Iterators

    • Assume we had a vector named ivec and we wanted to reset each of its elements to zero.We might do so by using a subscript:
    for(vector<int>::size_type ix=0;ix!=ivec.size();++ix)
    	ivec[ix]=0;		//reset all the elements in ivec to 0
    
    • A more typical way to write this loop would use iterators:
    for(vector<int>::iterator iter=ivec.begin();iter!=ivec.end();++iter
    
    The First The Second
    subscript ['sab skript]下标
    norm 范数
  • 相关阅读:
    ubuntu18安装net-snmp
    virtual box安装ubuntu系统 ping通 && xshell可以连接
    高中操场所见所思
    如何写好研究生开题报告
    在加州考驾照
    一个软件工程项目竞赛网站
    结对项目总结
    喜马拉雅随车听开通啦
    裘老师赠书
    推荐博客链接
  • 原文地址:https://www.cnblogs.com/hugeng007/p/9351729.html
Copyright © 2011-2022 走看看