+ 12
Is it possible to define a function of int type within another function of int type?
8 odpowiedzi
+ 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
+ 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.
+ 2
Nested functions are not allowed. but you can achieve that functionality by using lambdas
+ 2
yes u can..!!in c++ obviously
+ 1
that won't work in C....😎😎😎
+ 1
yes
+ 1
no we cannot use nested function
0
https://en.cppreference.com/w/cpp/utility/functional/function
,you may want look at this for more detail on functions in c++