怎么使用C++标准库来实现二维数组
来源:互联网 发布:数组排序最快的方法 编辑:程序博客网 时间:2024/05/22 04:48
在编程里,像界面布局是二维的,那么常常使用二维数组来表示界面的元素,那么就需要使用二维的数组,在现在C++肯定是以标准库为基础了,不再使用C的二维数组,那么怎么样做呢?下面就使用vector来实现二维数组的功能,代码如下:
// ConsoleApplication3.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <vector>#include <memory>#include <string>#include <iostream>using namespace std;int main(){//二维数组vector< vector< shared_ptr<string> > > vTest;vector < shared_ptr<string> > vTemp;vTemp.push_back(make_shared<string>("a"));vTemp.push_back(make_shared<string>("b"));vTemp.push_back(make_shared<string>("c"));vTest.push_back(vTemp);for (const auto& v : vTest){for (const auto p : v)cout << *p << endl;}//数组的访问方式cout << "vTest[0][0]: " << *vTest[0][0] << endl;cin.get(); return 0;}
在这里vector< vector< shared_ptr<string> > >
实现了二维数组的功能,使用也像二维数组一样。
1. 五子棋游戏开发
http://edu.csdn.net/course/detail/5487
2. RPG游戏从入门到精通
http://edu.csdn.net/course/detail/5246
3. WiX安装工具的使用
http://edu.csdn.net/course/detail/5207
4. 俄罗斯方块游戏开发
http://edu.csdn.net/course/detail/5110
5. boost库入门基础
http://edu.csdn.net/course/detail/5029
6.Arduino入门基础
http://edu.csdn.net/course/detail/4931
7.Unity5.x游戏基础入门
http://edu.csdn.net/course/detail/4810
8. TensorFlow API攻略
http://edu.csdn.net/course/detail/4495
9. TensorFlow入门基本教程
http://edu.csdn.net/course/detail/4369
10. C++标准模板库从入门到精通
http://edu.csdn.net/course/detail/3324
11.跟老菜鸟学C++
http://edu.csdn.net/course/detail/2901
12. 跟老菜鸟学python
http://edu.csdn.net/course/detail/2592
13. 在VC2015里学会使用tinyxml库
http://edu.csdn.net/course/detail/2590
14. 在Windows下SVN的版本管理与实战
http://edu.csdn.net/course/detail/2579
15.Visual Studio 2015开发C++程序的基本使用
http://edu.csdn.net/course/detail/2570
16.在VC2015里使用protobuf协议
http://edu.csdn.net/course/detail/2582
17.在VC2015里学会使用MySQL数据库
http://edu.csdn.net/course/detail/2672
阅读全文
0 0
- 怎么使用C++标准库来实现二维数组
- C++使用VARIANT实现二维数组的操作、怎么使用COleSafeArray实现二维数组将字符串写入excel
- c语言二维数组怎么表示
- 如何使用标准c语言来实现图像验证码
- 使用Vector实现二维数组
- 使用Vector实现二维数组
- 使用Vector实现二维数组
- C语言实现使用静态数组来构造栈结构
- C语言实现使用动态数组来构造栈结构
- 顺时针填充二维数组(c语言实现)
- C语言二维数组实现扫雷游戏
- C实例---二维数组(指针实现)
- 任意行列二维数组C语言实现
- [C++]重载二维数组下标 [ ][ ]实现二维矩阵
- C/C++二维数组的使用
- C中使用动态二维数组
- 【C++】使用new新建动态二维数组
- C语言--二维数组的使用
- 输入一个整数a,再输入两个整数p1,p2(p1,p2<32),输出该整数的二进制表示方法中从右端开始的p1到p2位.
- java 工具箱 AOP
- 彻底理解Python切片
- 1022: [SHOI2008]小约翰的游戏John
- JavaScript中数组的使用
- 怎么使用C++标准库来实现二维数组
- HttpSession详解
- CodeForces 835 A.Key races(水~)
- [USACO4.2.2]The Perfect Stall
- C语言递归李白打酒
- 单片机之按键
- 一个简单的文件分享工具
- 2017年前端面试题整理汇总100道题
- 强化练习8:将一个班级40位同学随机分成10组