mardi 24 octobre 2017

evaluation of passed paramaters in macros

#include<bits/stdc++.h>
#define prod(a) (a*a)
using namespace std;
int main()
{
int i=3,j,k,l;
j=prod(i++);
cout<<i<<endl;
k=prod(++i);
cout<<i<<endl;
l=prod(i+1);

cout<<i<<" "<<j<<" "<<k<<" "<<l;


    return 0;
}

Why is variable "i" incremented twice?

i.e to 5 from 3 after j=prod(i++);

Aucun commentaire:

Enregistrer un commentaire