Thursday, February 24, 2011

Default Arguments


#include<iostream.h>
#include<conio.h>

class find
{
public:
int a,b;

 void get(int x,int y=20)
 {
 a=x;
 b=y;
 }

 void display()
 {
 cout<<"\n A : " <<a<<"\n";
 cout<<"\n B : " <<b<<"\n";
 }

};

void main()
{
clrscr();

find ob;

ob.get(10);

ob.display();
find ob1;

ob1.get(20,30);

ob1.display();

getch();

}


No comments:

Post a Comment