+ 2
Can I declare pointer to function with default parameters? If can, the how?
5 Respuestas
+ 2
https://en.cppreference.com/w/cpp/language/default_arguments
"Default arguments are only allowed in the parameter lists of function declarations and lambda-expressions, (since C++14) and are not allowed in the declarations of pointers to functions, references to functions, or in typedef declarations."
I don't know what you need this for but you could make them overloads and have 2 function pointers/1 function pointer then cast to the overloaded type, or use a lambda/functor/another function that takes a default parameter that invokes your function through the function pointer (I don't see the point of doing this).
+ 2
Chirag Kumar see line with comment (//)
+ 1
UraL ohh ok didn't notice that.
I think you cant. I don't know the perfect explanation so can't help :)
But others will guide you !!
0
jtrh I don't need it. It was in SoloLearn challenge
0
jtrh thanx