In computer programming, a default argument is an argument to a function that a programmer is not required to specify. In most programming languages, functions may take one or more arguments. Usually, each argument must be specified in full (this is the case in the C programming language). Later languages (for example, in C++) allow the programmer to specify default arguments that always have a value, even if one is not specified when calling the function. Default arguments in C++ Consider the following function declaration: int MyFunc(int a, int b, int c = 12); This function takes three arguments, of which the last one has a default of twelve. The programmer may call this function in two ways: int result = MyFunc(1, 2, 3); result = MyFunc(1, 2); In the first case the value for the argument called c is specified as normal. In the second case, the argument is omitted, and the default value of 12 will be used instead. There is no means to know if the argument has been specified by the caller or if the default value was used. The above-mentioned method is especially useful when one wants to set default criteria so that the function can be called with or without parameters. Consider the following: void PrintGreeting(std::ostream& stream = std::cout) { // This outputs a message to the given stream. stream << "hello world!"; } The function call: PrintGreeting(); will by default print "hello world!" to the standard output std::cout (typically the screen). On the other hand, any object of type std::ostream can now be passed to the same function and the function will print to the given stream instead of to the standard output. PrintGreeting(std::cerr); Because default arguments' values are "filled in" at the call site rather than in the body of the function being called, virtual functions take their default argument values from the static type of the pointer or reference through which the call is made, rather than from the dynamic type of the object supplying the virtual function's body. struct Base { virtual std::pair<int, int> Foo(int x = 1) { return {x, 1}; } }; struct Derived : public Base { std::pair<int, int> Foo(int x = 2) override { return {x, 2}; } }; int main() { Derived d; Base& b = d; assert(d.Foo() == std::make_pair(2, 2)); assert(b.Foo() == std::make_pair(1, 2)); } Overloaded methods Some languages, such as Java, do not