Hello,
Queries about this example:
int addFunc(int a, int b){ return a + b; }
int main(){
auto addObj = [](int a, int b){ return a + b; };
}
Queries:
- Specific reason to use data type as auto?
- What does “[]” signifies here?
Hello,
Queries about this example:
int addFunc(int a, int b){ return a + b; }
int main(){
auto addObj = [](int a, int b){ return a + b; };
}
Queries:
Hi @Mak, Thanks for reaching out to us.
1. If the parameter type is generic, you can use the auto
keyword as the type specifier. This keyword tells the compiler to create the function call operator as a template. Each instance of auto
in a parameter list is equivalent to a distinct type parameter.
2. []
is called the lambda introducer which denotes the start of the lambda expression.
Hope this helps.
Happy Learning