Considering this piece of code
int main(int argc, char *argv[]) {
string a = "hello world";
void (*f) = []() {
cout << a << endl;
}
}
How can I define f
such that the type of f
is void (*f)(void)
? Without using [&]
.
The motive is that I want to store in a struct this function f
, but I don't want to give the struct a
.
How do I proceed?