Nic "nedefinovaneho" na tom neni. ++ je normalni funkce, akorat zapsana jako operator. Takze:++i si prepiste jako Kód: [Vybrat]int incr_pre(int &i) { i++; return i; } i++ prepiste jakoKód: [Vybrat]int incr_pos(int &i) { int tmp = i; i++; return tmp; } a je to jasny.Kód: [Vybrat]a[i] = incr_pos(i); // a[i] = i++;a[i] = incr_pre(i); // a[i] = ++i;a[incr_pos(i)] = incr_pre[i]; // a[i++] = ++i;Pro hnidopichy, ano neni to C, je to C++. Kdo chce C, at si prepise referenci na pointery.
int incr_pre(int &i) { i++; return i; }
int incr_pos(int &i) { int tmp = i; i++; return tmp; }
a[i] = incr_pos(i); // a[i] = i++;a[i] = incr_pre(i); // a[i] = ++i;a[incr_pos(i)] = incr_pre[i]; // a[i++] = ++i;
1) If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.i = ++i + 2; // undefined behavior until C++11i = i++ + 2; // undefined behavior until C++17f(i = -2, i = -2); // undefined behavior until C++17f(++i, ++i); // undefined behavior until C++17, unspecified after C++17i = ++i + i++; // undefined behavior2) If a side effect on a scalar object is unsequenced relative to a value computation using the value of the same scalar object, the behavior is undefined.cout << i << i++; // undefined behavior until C++17a = i++; // undefined behavior until C++17n = ++i + i; // undefined behavior