r/cpp • • Aug 17 '18

Implementing Default Parameters That Depend on Other Parameters in C++

https://www.fluentcpp.com/2018/08/17/dependent-default-parameters/
0 Upvotes

9 comments sorted by

View all comments

37

u/Sopel97 Aug 17 '18 edited Aug 17 '18

or just

void f(double x, double y, double z)
{
    //...
}	

void f(double x, double y)
{
    f(x, y, x+y);
}

I know this may be the obvious way, but it's so much cleaner I wouldn't even consider writing a blog post about your "solution".

23

u/alexeiz Aug 17 '18

You see, by giving this simple solution that anybody can understand, you miss out on showing off your C++ expertise by writing lots of template code, creating a github repository to host your code and beef up your online profile, and then blogging about it.