Sunday, 27 November 2011

C++ Program For (/)Divides Operator Overloading


#include<iostream.h>
#include<conio.h>
class test
 {
  int num;
  public:
  void operator /(test ob)
   {
    int div;
div=num/ob.num;
cout<<"div="<<div;
   }
  test(int x)
   {
    num=x;
   }
 };
 void main()
 {
   test t1(20),t2(4);
   t1/t2;
   getch();
 }

No comments:

Post a Comment