vector<int> vi(3);
for (int i=0; i<vi.size(); i++)
{
cout << vi[i] << endl;
}
output1:
0
0
0
vector<int *> vi(3);
for (int i=0; i<vi.size(); i++)
{
cout << vi[i] << endl;
}
output2:
0
0
0
vector<int *> vi(3);
for (int i=0; i<vi.size(); i++)
{
cout << &vi[i] << endl;
}
output3:
0x2b10b0
0x2b10b4
0x2b10b8
I don't understand why don't i see a difference in the outputs for parts 1 and 2. My expectation was that for part 2, since I have declared a vector of pointers to int, I should see something like output 3 but I don't. Could someone explain me why is it so.
The reason why I did this experiment was since I wanted to initialize a vector of pointers to float. I then want to pass these pointers to some functions that can modify values pointed to by these pointers. I shall then be using these values later in my program.