U
U
Umid2016-11-15 18:49:21
C++ / C#
Umid, 2016-11-15 18:49:21

Function declaration inside a function?

How can I declare a function inside a function, so that the compiler would not swear (Visual Studio Express);
For example in javascript it looks like this:

function func1() {
   ...
   function func2() {
      ...
   }
 }

How to do something similar in C++?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-11-15
@DarCKoder

int func1() {
    auto func2 = []() { return 42; };
    return func2();
}

stackoverflow.com/a/4324780/1510966
stackoverflow.com/a/4324829/1510966

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question