-/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: THIS PROGRAMM EXPLAIN THE CONCEPT OF OPERATOR OVERLOADING ::::
:::: IN C++ PROGRAMM DEVLOPED BY DX PANCHAL AT MCA LAB ::::
:::: ON DATED 18/04/2013 ::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/
//HEADER FILES DECLARATION
#include<iostream.h>
#include<conio.h>
//BEGIN CLASS DECLARATION
class temp
{
int a,b,ans;
public:
void getdata(int x,int y)
{
a=x;b=y;
};
void display()
{
cout<<"\n\t\tVALUE OF A=>"<<a<<"B=>"<<b;
};
void operator-();
};
void temp::operator-()
{
a=-a;b=-b;
};
//END OF TEMP CLASS
//MAIN FUNCTION MAIN
void main()
{
clrscr();
temp t;
t.getdata(10,20);
cout<<"\n\n\t\tDEACTIVE OPERATOR ::> ";
t.display();
cout<<"\n\n\t\tACTIVE OPERATOR ::> ";
-t;
t.display();
getch();
}
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::: THIS PROGRAMM EXPLAIN THE CONCEPT OF OPERATOR OVERLOADING ::::
:::: IN C++ PROGRAMM DEVLOPED BY DX PANCHAL AT MCA LAB ::::
:::: ON DATED 18/04/2013 ::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/
//HEADER FILES DECLARATION
#include<iostream.h>
#include<conio.h>
//BEGIN CLASS DECLARATION
class temp
{
int a,b,ans;
public:
void getdata(int x,int y)
{
a=x;b=y;
};
void display()
{
cout<<"\n\t\tVALUE OF A=>"<<a<<"B=>"<<b;
};
void operator-();
};
void temp::operator-()
{
a=-a;b=-b;
};
//END OF TEMP CLASS
//MAIN FUNCTION MAIN
void main()
{
clrscr();
temp t;
t.getdata(10,20);
cout<<"\n\n\t\tDEACTIVE OPERATOR ::> ";
t.display();
cout<<"\n\n\t\tACTIVE OPERATOR ::> ";
-t;
t.display();
getch();
}
No comments:
Post a Comment