Saturday 25 March 2017

increment - unary operators in c++

Why does (n2 equal to 5) and (n4 equalfrom the code below, could someone please explain in depth?



// declaration of variables
int n1, n2, n3, n4
n1 = 5;
n2 = n1++;
n3 = 5;
n4 = ++n3;
//outputs calculation
cout << n1 <cout << n4 << endl;

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...