Blogger news

Followers

Thursday, September 26, 2013
#include<iostream.h>
 #include<conio.h>

 class test
 {
   int x;
   int temp;
   public:
     void operator -();
     void read();
     void display();
 };
  void test::operator-()
  {
    x=-x;
  }
  void test::read()
  {
   x=20;
   temp=x;
  }
  void test::display()
  {
   cout<<"temp="<<temp<<endl;
   cout<<x<<endl;
  }

 void main()
  {
    test b;
    clrscr();
    b.read();
    -b;
    b.display();

    getch();
  }
Screenshot:

0 comments: