c ++,创建向量的向量? [英] c++, creating vector of vectors?

查看:220
本文介绍了c ++,创建向量的向量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是关于创建向量向量的向量的最佳方法是什么。我有几个向量< double>坐标; ,我想把它们传递给函数。我应该如何结合它们, vector< vector< double> > ?有更优雅的方式吗?

Question is about what is the best way to create vector of vectors. I have several vector<double> coordinates; and I want pass them to function. How I should combine them, vector<vector<double> >? Is there more elegant way?

推荐答案

这听起来像一个合理的方法。如果您担心可读性,请使用 typedef

That sounds like a reasonable approach. If you're worried about readability, then use a typedef.

但是,如果所有的向量都是相同的长度(例如,你真的试图创建一个2D数组),然后考虑使用 boost :: multi_array

However, if all of your vectors are the same length (e.g. you're really trying to create a 2D array), then consider using a boost::multi_array.

这篇关于c ++,创建向量的向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆