+ 12

Is it possible to define a function of int type within another function of int type?

28th Nov 2018, 5:39 PM
Mehak Jain
8 Respostas
+ 4
In standard c nested functions are not available. GCC has an extension that allows nested functions in c, but not in c++ (interestingly). There is a lot of discussion if nested functions are needed, bad or good. You can follow these discussions here: https://stackoverflow.com/questions/2608158/nested-function-in-c https://stackoverflow.com/questions/2929281/are-nested-functions-a-bad-thing-in-gcc And a lot more if you search for it. Documentation gnu.gcc http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html And finally a code I have written and is executable on sololearn: https://code.sololearn.com/cltJ97F9sCI9/?ref=app
30th Nov 2018, 8:12 AM
mimtelf
mimtelf - avatar
+ 3
In C, they are not possible, but in C++, you can use lambdas within a function. However lambdas are function objects, not just functions.
30th Nov 2018, 8:15 AM
Eragon1980
Eragon1980 - avatar
+ 2
Nested functions are not allowed. but you can achieve that functionality by using lambdas
29th Nov 2018, 1:52 PM
Seniru
Seniru - avatar
+ 2
yes u can..!!in c++ obviously
30th Nov 2018, 4:53 AM
Sumit Vishwakarma
Sumit Vishwakarma - avatar
+ 1
that won't work in C....😎😎😎
29th Nov 2018, 4:15 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 1
yes
29th Nov 2018, 8:42 PM
Elijah Limas
Elijah Limas - avatar
+ 1
no we cannot use nested function
2nd Dec 2018, 12:23 PM
Shubham Vijaykumar Patil
Shubham Vijaykumar Patil - avatar
0
https://en.cppreference.com/w/cpp/utility/functional/function ,you may want look at this for more detail on functions in c++
28th Nov 2018, 7:22 PM
Manas Shukla
Manas Shukla - avatar