zoukankan      html  css  js  c++  java
  • list-back

    ////////////////////////////////////////
    //      2018/04/25 21:05:50
    //      list-back
    
    // return the last element
    #include <iostream>
    #include <list>
    #include <algorithm>
    #include <string>
    #include <iterator>
    
    using namespace std;
    
    template<class T, class D>
    class Member{
    private:
        T name;
        D sal;
    public:
        Member(T t, D d) :name(t), sal(d){};
        void print();
    };
    
    template<class T, class D>
    void Member<T, D>::print(){
        cout << name << " " << sal << endl;
    }
    //--------------------------
    int main(){
    
        typedef Member<string, double> M;
        list<M> l;
    
        l.push_back(M("Robert", 60000));
        l.push_back(M("Linda", 75000));
    
        list<M>::iterator it = l.begin();
        cout << "Entire list:" << endl;
        while (it != l.end()){
            (it++)->print();
        }
        cout << endl;
    
        cout << "Return from back()" << endl;
        l.back().print();
        return 0;
    }
    
    
    /*
    OUTPUT:
        Entire list:
        Robert 60000
        Linda 75000
    
        Return from back()
        Linda 75000
    */ 
  • 相关阅读:
    scrapy框架
    selenium解析
    xpath解析
    解析语法
    request-html-render
    牛逼的requests-html
    Beautifulsoup
    请求和响应
    reuqests请求
    Django文件上传下载与富文本编辑框
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12537975.html
Copyright © 2011-2022 走看看