This is called a "default argument". That is, if the user doesn't pass a second value to func
, the function will receive 0
For example:
int func(std::vector<int> a, int lum=0)
{
std::cout << "Received lum value: " << lum << std::endl;
}
int main(){
std::vector<int> a = {1, 2, 3};
func(a); // "Received lum value: 0"
func(a, 2); // "Received lum value: 2"
}
cppreference has a good page on this.
All default arguments must appear last in a function's declaration, and should not appear again in a function's definition if you choose to separate declaration and definition:
int func(std::vector<int> a, int lum=0); // declaration
// ...
int func(std::vector<int> a, int lum){ // definition, no default arguments
//...
}