The std :: vector in C++ stores the objects in contiguous memory locations. But when I print the address, I find that this does not happen. Please let me know why. The code is here:
#include <iostream>
#include <vector>
using namespace std;
class a
{
int val1;
};
vector<a> records(10);
int main()
{
int i;
for(i=0;i<12;i++)
cerr<<"address"<<i<<"="<<&records[i]<<endl;
}
The output I get is not contiguous in memory.