+ 3

Passing function as argument, to same function

A question has been asked here: https://www.sololearn.com/Discuss/2484139/?ref=app I don't know how it's working, since the function add() doesn't accepts any parameter, yet, it receives the add() function as an argument and calculates the sum twice https://code.sololearn.com/cMZdR8U68haX/?ref=app

7th Sep 2020, 10:07 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
4 Respuestas
+ 2
adding () will make the function evaluate, and empty parameter function in c doesnt meant it cant recieve an argument, but it also doesnt have a way to access it either if an argument are given. so it just ignored what ever arguments passed
7th Sep 2020, 10:28 AM
Rei
Rei - avatar
+ 1
Rei Shouldn't the function add() recieve a function pointer ? And why would be the inner returned value be ignored??
7th Sep 2020, 10:16 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
7th Sep 2020, 10:29 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
inner add() will evaluate, the return value will be used in as argument to outer add() but ignored, then outer add() evaluate
7th Sep 2020, 10:13 AM
Rei
Rei - avatar