r/cpp • u/anonymous23874 • Apr 19 '20
Default function arguments are the devil
https://quuxplusone.github.io/blog/2020/04/18/default-function-arguments-are-the-devil/
90
Upvotes
r/cpp • u/anonymous23874 • Apr 19 '20
View all comments
1
u/DVMirchev C++ User Group Sofia Apr 22 '20
If you want to add to the confusion there is also default function arguments initialized by a function call.
#include <iostream>void moo(int a = [](){ static int b = 1; return b++; }() ){std::cout << a;}int main(){moo();moo();}Anyone care to guess what's happening here without googling? :D