I have a vector and want to store int data in to it at run time can I store the data in a 2D vector in this manner ?
std::vector> n
You cannot directly assign to [i]
without allocating the outer and inner vectors first. One solution to this would be to create the inner vectors inside your for loop, then once those are populated, push_back to the outer vector.
std::vector> normal;
for(i=0;i<10;i++)
{
std::vector temp;
for(j=0;j<20;j++)
{
temp.push_back(j);
}
normal.push_back(temp);
}