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?
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.
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