how to print out element address of vector of vector

Posted 07 February 2011 - 08:38 AM

i have a vector of vector.
vector< vector<double> out_list.

here, inner vector contains only two elements. so my vector of vector stores values like, {{a1,b1},{a2,b2},{a3,b3},...}
i need to print out address of {a1,b1}, {a2,b2},...and so on. the addresses will be 0,1,2,3,..

I just tried with vector<int>, to print out its element address first. here is my code.

Re: how to print out element address of vector of vector

Posted 07 February 2011 - 08:47 AM

I don't understand what you are trying to do, what you are doing now is printing out the address of each vector item. Are you trying to print out the contents of the vector? If you want the value held in position 3 of the vector then you could just use array notation cout << x[3] << " ".

So, I need to use 2 loops to incorporate these two data sets. Each integer in the map (either key or data item) refers to one index of vector of vector. What I wanted is, to access these inside vector according to the order given by the map.
I hope, it is now clear.

Re: how to print out element address of vector of vector

Posted 07 February 2011 - 01:23 PM

Vectors are really just dynamic arrays ...
And they allow access using array index notation.
So ... can access like this:
vAry[0][1]
where the first 0 index specifies the index of the outer vector container
and the second 1 index specifies the index of the inner vector container.