C++ multi-D vectors | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

C++ multi-D vectors

which c++ standard allows the declaration of a multi - dimensional vector in a class in header file and its population in the cpp file? my ide shows weird errors when I try that.

9th Mar 2017, 5:32 AM
Clement Phomane
Clement Phomane - avatar
1 Answer
+ 2
#include <vector> ... //2-D vector of vector vector<vector<dataType> > mVector; vector<dataType> mRow; mRow.push_back(data); mRow.push_back(data); mRow.push_back(data); mVector.push_back(mRow); mRow.clear(); .... continue to push vectors onto the 2-D vector. you can access them as mVector[0][0] ***check out my file: cpp_2DVectorSummary in my profile for more help. hopes this helps
10th Mar 2017, 4:46 AM
Michael Szczepanski
Michael Szczepanski - avatar