r/cpp • • Apr 19 '20

Default function arguments are the devil

https://quuxplusone.github.io/blog/2020/04/18/default-function-arguments-are-the-devil/
92 Upvotes

149 comments sorted by

View all comments

Show parent comment

6

u/robin-m Apr 19 '20

Especially given that you can have declaration and implementation that can be in different files. So if the first case you have:

explicit Widget(int size);
explicit Widget(int size, int start);

Witch is anything but explicit.

In the second case, it will be:

explicit Widget(int size, int start='A');

4

u/sphere991 Apr 19 '20

Didn't even think of that, good point.

Also I find the typo on "witch" to be really funny, in the context of describing something as being "the devil". Please don't fix it :-)

3

u/Raknarg Apr 19 '20

Sneaky witches, always going around implicitly