<<< Array of objects and default constructor | Index | More function default parameters >>> |
C++ functions can have default parameters:
void print( int value, int base = 10 );
void f()
{
print( 31 ); // uses default
print( 31, 8 ); // overrides default
print( 31, 10 ); // same as first call
}
Same as
void print( int value, int base ); void print( int value ) { print( value, 10 ); }
But only trailing arguments can be defaulted:
void func_one( int x, int y = 0 ); // Ok
void func_two( int x = 0, int y ); // Error!
<<< Array of objects and default constructor | Index | More function default parameters >>> |