I use something like this
Now i need to pass a to a function called func...Code:vector<pair<int, int> >a[100001];
How will the call look like..
gives errorCode:func(a)
I use something like this
Now i need to pass a to a function called func...Code:vector<pair<int, int> >a[100001];
How will the call look like..
gives errorCode:func(a)
a is an array of vectors. Are you sure you want an array of vectors? If you did, then make sure your function accepts an array of vectors. If you wanted just a vector, but with 100001 elements, then you need to call the constructor, not declare an array:
Code:vector<pair<int, int> >a(100001);
Yes i need exactly what i posted...
There is no prob with the function..
I define it this way
Code:void func(vector<pair<int, int> > a[])
And then ...Code:void func (vector <pair <int, int> >* a) { a[0][0] = make_pair (7, 8); // do something with a... }
Code:vector <pair <int, int> > a[100001]; a[0].push_back (make_pair (5, 6) ); func (a); cout << a[0][0].first << endl; cout << a[0][0].second;
fine ll try
well,rossipoo you were a great help
just out of curiosity, why do you need a c-style array of vectors? why not use another vector to contain the array?
that will work fine until it grows very large, and the reallocation exhausts the available memory on the machine. we had a thread about that a while back, where inserting an item caused it to attempt to allocate more than the 2GB available to the process. if you know how big it will be, the best bet is to reserve the space ahead of time, then it will never need to re-allocate memory.