Friday 19 April 2013

- OPERATOR LOADING IN C++

/*
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::: 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

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...