Incrementing many times within a function call

I have a class with a constructor which takes a series of arguments:
Property::Property(QString _name, QString _gamma, QString _k0, QString _cohesion, QString _phi)
However, the values of these arguments are given by a generic dialog which returns a vector.

I was hoping to be able to do the following:
1
2
3
4
5
for(vector<QString>::iterator pit=props.begin();pit!=props.end();)
{
   Property p(*pit++,*pit++,*pit++,*pit++,*pit++);
   //do stuff with "p"
}


However, the values that appear are random. The first one (_name) becomes an empty string, the last one (_phi) gets the value of the second element of the vector... it's quite a mess.

Is there a way of doing this? Or do I in these cases need to do each member of p individually?
1
2
3
4
5
p.name=*pit++;
p.gamma=*pit++;
p.k0=*pit++;
p.cohesion=*pit++;
p.phi=*pit++;

I've done this and it works, but I was just hoping to clean it up a bit by placing it all in the constructor.
I don't think the order of evaluation of parameter is defined at all. They are passed according to a calling convention (the default is right to left (__cdecl), AFAIK), but that doesn't mean they're evaluated in that order.
Didn't think so. Manual it is, then.
If is a vector::iterator you could add an integer.
Property p(*(pit+0),*(pit+1),*(pit+2),*(pit+3),*(pit+3) );
Or you could use an index and the [] operator
Last edited on
Adding an integer is quite obvious and brilliant. Thanks.
Topic archived. No new replies allowed.