• deque-push_front


    ////////////////////////////////////////
    //      2018/04/24 20:09:27
    //      deque-push_front
    
    #include <iostream>
    #include <deque>
    #include <string>
    #include <iterator>
    
    using namespace std;
    template<class T>
    class Name{
    private:
        T name;
    public:
        void print(){
            cout << name << " ";
        }
        Name(T t) :name(t){}
    };
    //=========================
    int main(){
        typedef Name<string> N;
        typedef deque<N> D;
        D d;
        N n1("Robert");
        N n2("Alex");
        d.push_front(n1);
        d.push_front(n2);
    
        // unnmaed object of the type Name
        d.push_front(N("Linda"));
        D::iterator it = d.begin();
        while (it != d.end()){
            (it++)->print();
        }
        cout << endl;
        return 0;
    }
    
    
    /*
    OUTPUT:
      Linda Alex Robert
    */ 
  • 相关阅读:
    05-----数据类型转换
    04-----赋值运算符
    03-----数据类型
    02-----第一个JavaScript代码
    Fxx and game
    Bomb
    Stammering Aliens
    DISUBSTR
    Life Forms
    后缀数组二·重复旋律2
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12537988.html
Copyright © 2020-2023  润新知