-
-
Notifications
You must be signed in to change notification settings - Fork 21
Anonymous Functions
CD2 edited this page Feb 8, 2023
·
1 revision
Anonymous functions can only be called with function pointer calls. Anonymous functions can refer to local variables. Anonymous functions cannot be defined on class members or globally.
If the function definition is enclosed in [] without writing the name, it becomes an anonymous function literal. Anonymous function literals can be written inside expressions.
void f()
{
int sum = [int(int a, int b){ret a + b;}](:1, 1:);
}