vendredi 25 septembre 2020

What is the output of the given code ? and explain why it is coming

I am not able to understand, why the output of the code is not what I was expecting.

#include <iostream>
using namespace std;
int main()
{
    int m = 2, n = 6;
    int &x = m;
    int &y = n;
    m = x++; 
    x = m++;
    n = y++;
    y = n++;
    cout<< m << " " << n; 
    return 0; 
}

I was expecting 4 8

Aucun commentaire:

Enregistrer un commentaire