Skip to content

Instantly share code, notes, and snippets.

@xkikeg
Created December 10, 2011 10:21
Show Gist options
  • Save xkikeg/1454911 to your computer and use it in GitHub Desktop.
Save xkikeg/1454911 to your computer and use it in GitHub Desktop.
演算子の評価順序が不定であることを示している例?
#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