Below code snippet is From Herb Sutter's blog here
g++ outputs 10. MSVC also does output 10. Output could be different on different compilers.
I fail to understand how variable i is incremented. Can anyone explain me how come output is 10, Is 10 really correct output?
#include <iostream>
#include <vector>
#include <string>
int main()
{
std::vector<int> v = { 0, 0 };
int i = 0;
v[i++] = i++;
std::cout << v[0] << v[1] << std::endl;
}
Aucun commentaire:
Enregistrer un commentaire