Demonstrate default arguments : default arguments « Function « C++ Tutorial






#include <iostream>  
using namespace std;  
 
void f(int x = 0, int y = 100); 
 
int main()  
{  
  f(1, 2); 
 
  f(10); 
 
  f(); 
 
  return 0; 
} 
 
void f(int x, int y) 
{ 
  cout << "x: " << x << ", y: " << y << "\n"; 
}
x: 1, y: 2
x: 10, y: 100
x: 0, y: 100








7.6.default arguments
7.6.1.Demonstrate default arguments
7.6.2.Function with two regular parameters and one parameter with default value
7.6.3.Use two default parameter values
7.6.4.Ambiguous function call with function with default parameter value
7.6.5.Using multiple default parameter values: defaults for reference parameters
7.6.6.demonstrates missing and default arguments