FACTOID # 182: Ukraine is the breadbasket of Europe, and the world's largest producer of barley and total coarse grain per gdp.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

Encyclopedia > Default argument

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 some value, even if the calling program do not write them. For example, in the following function definition:

 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:

 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 one, the argument is omitted, and the default 12 value will be used instead.


The called function has no way of knowing if the argument has been specified by the caller or using the default value.


  Results from FactBites:
 
Argument - Wikipedia, the free encyclopedia (426 words)
argument (literature), the brief summary at the beginning of a section of a poem
Argumentative, a type of evidentiary objection to a question for a witness during a trial
Default argument, an actual parameter to a program that is used when no other actual parameter is provided
Parameter (computer science) - Wikipedia, the free encyclopedia (643 words)
Parameters are also commonly referred to as arguments, though arguments are more properly thought of as the actual values or references assigned to the parameter variables when the subroutine is called at runtime.
Some programming languages allow for a default argument to be explicitly or implicity given in a subroutine's declaration.
If the default argument is implicit (sometimes by using a keyword such as Optional) then the language provides a well-known value (such as null, Empty, zero, an empty string, etc.) if a value is not provided by the caller.
  More results at FactBites »

 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your location
Your comments
Please enter the 5-letter protection code


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.