zoukankan      html  css  js  c++  java
  • deque-constructors

    ////////////////////////////////////////
    //      2018/04/22 7:39:22
    //      deque-constructors
    
    #include <iostream>
    #include <deque>
    #include <string>
    #include <algorithm>
    
    using namespace std;
    
    int main(){
        string str[] = { "Alex", "John", "Robert" };
    
        //empty deque object
        deque<int> d1;
    
        // ceates deque with 10 empty elements
        deque<int> d2(10);
    
        //creates deque with 10 elements, and assign value 0 for each
        deque<int> d3(10, 0);
    
        //creates deque and assigns values from string array
        deque<string>d4(str + 0, str + 3);
    
        deque<string>::iterator slt = d4.begin();
        while (slt != d4.end())
        {
            cout << *(slt++) << " ";
        }
        cout << endl;
    
        // copy constructor
        deque<string> d5(d4);
    
        for (int i = 0; i < 3; i++){
            cout << d5[i] << " ";
        }
        cout << endl;
        return 0;
    }
    
    
    /*
    OUTPUT:
        Alex John Robert
        Alex John Robert
    */ 
  • 相关阅读:
    C++中的异常
    Hadoop YARN介绍
    js处理层级数据结构的一些总结
    Python数据结构
    Python的编码风格
    Python流程控制
    java中面试可能会问的问题
    深度学习
    Pescal Triangle Two
    Pascal Triangle
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12538018.html
Copyright © 2011-2022 走看看