Created
December 10, 2011 10:21
-
-
Save xkikeg/1454911 to your computer and use it in GitHub Desktop.
演算子の評価順序が不定であることを示している例?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(){ | |
int i,j; | |
i = 3; | |
j = 5; | |
// compiled with g++ | |
cout << "i = " << i++ << i++ << endl ; | |
// -> 43 | |
cout << "i = " << ( i = j ) << ( j = 6 ) << endl; | |
// -> 66 | |
cout << " i = " << ( i = j ) << ( j = 6 ) << ", j = " << ( j = 7 ) << endl; | |
// -> i = 66, j = 6 | |
cout << " i = " << i++ << ", " << " i = " << i++ << ", " << " i = " << i++ << ", " << " i = " << i++ << i << ", " << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment