zoukankan      html  css  js  c++  java
  • const vector<int> 和 vector<const int>问题讨论

    1、const vector <int> vec(10) —— 与const int a[10]是一回事,意思是vec只有10个元素,不能增加了,里面的元素也是不能变化的

    vector<int> a(10);
    const vector<int> b(10);
    a[1]=10;//正确
    b[1]=10;//错误
    a.resize(20);//正确
    b.resize(20);//错误
    

     2、关于vector<const int> ,在GCC下是没有这种用法的,编译不过,不过在VS2005下这样是可以的,不过它好像是把其当作vector<int>来处理的,赋值和resize都是可以的。

  • 相关阅读:
    php 解析xml
    php
    php 设置自动加载某个页面
    Mac
    mysql
    Git
    C#
    C# 正则表达式
    C# ASCII码排序
    (转)datagridview 自定义列三步走
  • 原文地址:https://www.cnblogs.com/yongbufangqi1988/p/3556080.html
Copyright © 2011-2022 走看看