C++/vector of vectors
I have greated a class which has a private member
called graph, which is a vector of vectors. I also have an inner class, declared in my public methods called edge. Now, graph is a vector full of Edge Vectors.
vector<vector<edge> > graph;
Suppose I have a filled edge vector called Temp;
How do I get it inro the graph, say at index 0?
I have tried graph.push_back(Temp).
I get an error
Can you help?
Replace vector<vector<edge> > graph; by
typedef vector <edge> newTirra;
vector <newTirra> graph;
The following code would help you in that:
# include <iostream>
# include <iterator>
# include <vector>
using namespace std;
int main ()
vector < int > vectorOfInt;
typedef vector <int> newType;
int x = 10;
cout << "Enter an integer" << endl;
int z ;
cin >> z;
vector <newType> dArr;
/* vector <int> ::iterator iter = vectorOfInt.begin();
for (; iter != vectorOfInt.end(); ++iter)
cout << *iter << endl;*/
vector <int> ::iterator iter = dArr.begin();
for (; iter != dArr.end(); ++iter)
cout << *iter << endl;
cin >> x;