source file name: optor1.cpp

 #include<stdio.h>

#include<conio.h>

#include<iostream.h>

class Alpha

{

int x,y,z;

public:

void getdata(int a, int b,int c)

{

x=a;

y=b;

z=c;

}

void show()

{

cout<<"  "<<x <<"  "<<y <<"  "<<z<<endl;

}

void operator-()

{

x= -x;

y= -y;

z= -z;

}

};


void main()

{


clrscr();

cout<<"Operator overloading program: ";

Alpha A;

A.getdata(10,25,30);

cout<< "\n A= ";

A.show();

-A;

cout<<"\n after applying operator(-) function values becomes -ve ";

cout<< "\n A= ";

A.show();

getch();

}

Output:

Operator overloading program

A=10 25 30

after applying operator(-) function values becomes -ve

A= -10 -25 -30