DESCRIPTION-:Default arguments are one who's values are initialized in the function definition(means when we declare the argument in function definition).The value of all the default arguments remains same throughout the program unless it is changed in the function call.
As explain in the below program how function call effect the default arguments.
PROGRAM-:
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void volume(int l=10,int w=10,int h=10);
void main()
{
clrscr();
volume(); //equivalent to (10,10,10)//
volume(5); //equivalent to (5,10,10)//
volume(5,6); //equivalent to (5,6,10)//
volume(6,4,5); //equivalent to(6,4,5)//
getch();
}
void volume(int l,int w,int h)
{
cout<<"volume is"<<l*w*h<<"\n";
}
As explain in the below program how function call effect the default arguments.
PROGRAM-:
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void volume(int l=10,int w=10,int h=10);
void main()
{
clrscr();
volume(); //equivalent to (10,10,10)//
volume(5); //equivalent to (5,10,10)//
volume(5,6); //equivalent to (5,6,10)//
volume(6,4,5); //equivalent to(6,4,5)//
getch();
}
void volume(int l,int w,int h)
{
cout<<"volume is"<<l*w*h<<"\n";
}
0 comments:
Post a Comment