0

How did this value come out : -2

int func(int a=2, int b=5){ return b-a; } int main (){ int k=7; cout<<func(k); }

5th Aug 2020, 7:31 PM
Vladimir Kushner
Vladimir Kushner - avatar
1 Antwort
+ 3
Since you have default values 2 and 5 in function params if you call function without params you get 3, BUT since you call function with k=7, param a become equal to 7 and param be still 5 so b-a = -2
5th Aug 2020, 8:10 PM
george
george - avatar