Saturday, June 11, 2016

Prefix operator difference in C++ and C#

Let's have this piece of code:



int a = 1;
int b = ++a + ++a;



In C++ (VS 2010) the result is: b = 6
but in C# the result is: b = 5



What's going on there? Why are the results different?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...