In article <11**********************@b28g2000cwb.googlegroups .com>,
kd*******@gmail.com says...
hi, all
If I am using gcc, is the sequence of excution in "if" the same as what
I wrote? Here is an example:
vector<intv;
unsigned short a;
....
if (a < v.size() && v[a] 0)
cout<<v[a];
I expect that the "a < v.size()" will excute first so that I won't get
into the segmentation error in cas of a v.size(). But I am not sure
if gcc will do in this way. Thanks for your comments.
You've had a number of correct replies already, but I thought it was
worth adding one point that they didn't really make clear: this
really has nothing to do with the 'if' statement. It's a
characteristic of the '&&' (and '||', for that matter) that happens
whether it's inside of an if statement or not.
--
Later,
Jerry.
The universe is a figment of its own imagination.