+ 6
I got 3 as output. Is that what you get?
What's the correct output you are expecting and why?
+ 3
AteFishđ§đ© read this article it's very well explained..
http://icarus.cs.weber.edu/~dab/cs1410/textbook/6.Functions/inline.html
+ 2
AteFishđ§đ©
Your code is working how it's suppose to be here.
(But it's also compiler dependent)
Try running this code, you'll notice that only after calling the inline function the value of x is incremented(since its post increment, try with pre increment ++x once, you'll get 3)
#define un(i) (i>=0?i:-i)
#include <iostream>
using namespace std;
inline int c(int x){
return x>=0?x:-x;
}
int main() {
int a=2;
cout<<un(a++)<<endl;
int x=2;
cout<<c(x++)<<endl;
cout << x << endl; // x is 3
return 0;
}
I found a very good explanation here...
https://stackoverflow.com/questions/11060968/using-the-post-increment-in-function-arguments#:~:text=When%20calling%20a%20function%20(whether,statements%20in%20the%20function%20body.
+ 2
Ashmaupadhyay
Please do not create spam threads or add spammy comments to an existing thread. Both are seen as negative behavior.
Thanks and happy coding
https://code.sololearn.com/Wv5gTHy1N6Ji/?ref=app