Friday, May 1, 2009

Implementing function overloading

header files


class swap

{

int a,b,c;

float x,y,z;

char p[10];

char ch,ch1;

public:

swap()

{

a=20;

b=40

}

swap(int x, int y)

{

a=x;

b=y;

}

swap(float a, float b, int aa)

{

x=a;

y=b;

c=aa;

}

swap(char s[10])

{

strcpy(p,s);

}

void display1()

{

cout<<>

}

void display1()

{

cout<<>

}

void display1()

{

cout<<>

}

};

void main()

{

clrscr();

swap obi();

swap obj1(6,15);

swap obj2(2.4,5.6,6);

swap obj3("god");

obj.display1();

obj1.display2();

obj2.display3();

obj3.display1();

}

No comments:

Post a Comment