|
-
March 7th, 2011, 10:03 AM
#16
Re: Do functions compute before being called?
One more question So you guys are saying that the order of evaluation in the statements I have written is undefined. E.g. D_Drmmr said,
"No, the order in which output appears on the screen is the same as the order in which std::cout is called. The problem with your original program is that there are two calls to std::cout (one in sd and one in main), who's order is unspecified."
But yet - the output of this program is ALWAYS A:
"Input array element 0: 5
Input array element 1: 7
Input array element 2: 9
7
The standard deviation of these numbers is 1.63299."
And never, for example, B:
"Input array element 0: 5
Input array element 1: 7
Input array element 2: 9
The standard deviation of these numbers is 7
1.63299."
If it were undefined surely the 7 would NOT ALWAYS be before the final sentence? What am I missing here? It seems to me that the order of evaluation is somehow defined.
I am still unsure of when/where exactly my function is executed.
Thanks again
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|