c++ set functions specific default argument

Hello everyone!

I'm not quite if I've seen it around, I did not find it on internet but
I believe that there was a way to set an specific argument while calling a function and leaving other's untouched.

Something like this:
1
2
3
4
5
6
void example( a = 5, b = 10, c = 15 ){ cout << a << "," << b << "," << c << endl; }
int main(){
    example( .b=20 ) // prints:5,20,15
    example( .c=100 ) // prints:5,10,100
    return 0
}


or perhaps I'm just confusing everything with another programming language
and that method does not exist at c++ at all.
Thanks!
Last edited on
Personally, I can't believe that you ask a pretty ridiculous question here even though you have up to 168 posts on the forum.

Do you need to learn C++ Default Parameters from scratch?
http://www.learncpp.com/cpp-tutorial/77-default-parameters/
Perhaps I'm blind or very stupid but I fail to see what I requested.
Take a closer look of my request.
C++ does not have named parameters. There is a workaround. See:
https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Named_Parameter


PS. Ignore the incompetent troll.
Thank you!
Topic archived. No new replies allowed.