+ 1
What should be the output of the program and why??
3 Réponses
+ 2
You have specified your function as void fun().
This means, it doesn't take an argument.
In main, you write fun(fun());, so you are giving an argument.
Just write fun(); and it will work.
+ 2
If the fun() argument would just evaporate, that might be the case, but it doesn't seem to work like that.
It is just checked (I don't know how exactly) that you pass something (a void expression) although you shouldn't.
Personally, I wouldn't even look further into it.
'Ah, I passed something although I shouldn't - silly me.'
If you want a deeper interpretation... hm... I hope someone else can provide it. ;-)
0
But the written type of fun is void so it does not return anything. So in fun(fun()), as inside fun() will get executed, it will return nothing. So fun(fun()) should be same as two times fun() ;