Index, assignment and increment in one statement behaves differently in C++ and C#. Why?

后端 未结 7 883
醉酒成梦
醉酒成梦 2021-01-18 16:34

Why is this example of code behaving differently in c++ and C#.

[C++ Example]

int arr[2];
int index = 0;
arr[index]         


        
相关标签:
7条回答
  • 2021-01-18 17:30

    Your C++ code could, in fact, do anything. arr[index] = ++index; invokes undefined behaviour.

    0 讨论(0)
提交回复
热议问题