D
dejan budimir
hi there!
#include <iostream>
using namespace std;
void main(){
int i=0,
j=10;
//Case one (the 'common' case):
cout<< "i == " << i << endl
<< "j == " << j << endl;
//Case two (the 'oddity'):
//Should print 1 and 11 (but will not evaluate the former expression
// before the latter, although it is printing in the correct order.
cout<< "(i+=1) == " <<(i+=1)<< endl
<< "(j+=i) == " <<(j+=i)<< endl;
}
The ostream's operator<<() method is defined as to be passed only two
arguments a time, one of which must be the class, which is being
returned to allow concatenation.
(cout<<expr1)<<expr2;
But it seems as if the whole set of expressions is being evaluated,
_before_ becoming the arguments of the operator methods and, in
addition, is being evaluated from the right to the left (from the
stack?).
Is this a microsoft-specific way of dealing with concatenation?
Havv ei got zee opchions wronk?
#include <iostream>
using namespace std;
void main(){
int i=0,
j=10;
//Case one (the 'common' case):
cout<< "i == " << i << endl
<< "j == " << j << endl;
//Case two (the 'oddity'):
//Should print 1 and 11 (but will not evaluate the former expression
// before the latter, although it is printing in the correct order.
cout<< "(i+=1) == " <<(i+=1)<< endl
<< "(j+=i) == " <<(j+=i)<< endl;
}
The ostream's operator<<() method is defined as to be passed only two
arguments a time, one of which must be the class, which is being
returned to allow concatenation.
(cout<<expr1)<<expr2;
But it seems as if the whole set of expressions is being evaluated,
_before_ becoming the arguments of the operator methods and, in
addition, is being evaluated from the right to the left (from the
stack?).
Is this a microsoft-specific way of dealing with concatenation?
Havv ei got zee opchions wronk?