Reputation: 1214
I cannot understand why would Visual Studio Intellisense complain. In the code:
int absolute_value(int x) {
return x > 0 ? x : - x;
}
It underlines x
in return x
with the message: return value type doesn't match the function return type.
Upvotes: 0
Views: 104
Reputation: 954
My environment is win10, vs2022. I tested the code you posted, the code works fine, I suggest you repair your Visual Studio or download it again.
#include<iostream>
using namespace std;
int absolute_value(int x) {
return x > 0 ? x : -x;
}
int main()
{
cout << absolute_value(-6);
}
Upvotes: 1