C++: Adding and redefinition of default arguments in real world
问题 There is a possibility to add or redefine default arguments of a function in C++. Let's look at the example: void foo(int a, int b, int c = -1) { std::cout << "foo(" << a << ", " << b << ", " << c << ")\n"; } int main() { foo(1, 2); // output: foo(1, 2, -1) // void foo(int a, int b = 0, int c); // error: does not use default from surrounding scope void foo(int a, int b, int c = 30); foo(1, 2); // output: foo(1, 2, 30) // void foo(int a, int b, int c = 35); // error: we cannot redefine the