still struggling with vectors

Pages: 12
std::vector<T>::iterator is a random access iterator. That means that you could use iter[i] if you want.
You may find this useful
http://cplusplus.com/reference/algorithm/fill_n/
http://cplusplus.com/reference/algorithm/generate_n/
http://cplusplus.com/reference/std/iterator/back_insert_iterator/

However, AFAICS your function doesn't care that you pass a vector. So
1
2
3
4
5
long readDataFile(string file, long	nbrCells, SocReg *a);

vector<SocReg> modHostValues;
//...
eadDataFile (s, NBR_COEFFS_BW, &(modHostValues[MOD_BWC00]) );
should work
By the way, ¿did you manage to fix your issue with the constructor?
Hi, ne555 -

Thanks for your response about passing a vector. I didn't think it worked the first time I tried it, but...it was probably an error on my part. I'll experiment some more this evening.

And yes, I think we agreed that the constructor will indeed work the way I originally expected. The gdb was lying to me a little bit (OK, not really, but its method of displaying vectors was rather misleading). I think I'm good here.
Topic archived. No new replies allowed.
Pages: 12