c++11的foreach用法
2015-09-17 16:19
501 查看
#include <stdlib.h> #include <stdio.h> #include <vector> #include <iostream> using namespace std; int main(int argc, char* *argv) { vector<int> vct; vct.push_back(100); vct.push_back(100); vct.push_back(100); vct.push_back(100); vct.push_back(100); vct.push_back(100); vct.push_back(100); vct.push_back(100); for ( int& value : vct ) { cout << value << endl; } return 1; }
[~/test]g++ -std=c++11 1.cpp [~/test]./a.out 100 100 100 100 100 100 100 100
相关文章推荐
- C语言小游戏 - 俄罗斯方块
- 浅谈C++中对象的复制与对象之间的相互赋值
- C语言二维数组剖析【元素及元素地址的指针操作】
- c++11基础学习(2)std::bind与std::function特性
- C++ 函数指针
- Python C++ interoperability
- c语言小工具
- Effective C++ ——初始化
- C++ Primer Plus(第6版) 第2章编程练习
- WinRT C++ byte* 转为 Ibuffer^(笔记)
- C++的异常处理
- C++中对象的常引用、动态建立和释放相关知识讲解
- 深入理解C++
- STL之vector的实现
- Effective C++ 改善程序与设计的55个具体做法 二周目笔记03
- 解析C++中指向对象的指针使用
- STL中的uninitialize系列
- Eclipse cdt c++11 blade 设置
- OSX Missing C++ header <__debug>修复
- C/C++结构体和类中的内存对齐