C++ Function Parameter missing and default arguments

Description

C++ Function Parameter missing and default arguments

#include <iostream>
using namespace std;
void repchar(char='*', int=45);   //declaration with
//default arguments
int main()/* w  ww.ja  v  a  2s  .  c  om*/
{
   repchar();                     //prints 45 asterisks
   repchar('=');                  //prints 45 equal signs
   repchar('+', 30);              //prints 30 plus signs
   return 0;
}
// displays line of characters
void repchar(char ch, int n)      //defaults supplied
{
   for(int j=0; j<n; j++)
      cout << ch;
   cout << endl;
}



PreviousNext

Related