Monday 4 February 2013

operator overloading in c++

#include<iostream.h>
#include<conio.h>

//THE OPERATORS {DOT OPERATOR (.), SCOPE RESOLUTION OPERATOR(::), CONDITIONAL OPERATOR(?:), POINTER TO MEMBER
//OPERATOR(->)} CAN NOT BE OVERLOADED NEITHER A NEW CREATED OPERATOR(ie *&) CAN BE OVERLOADED

class count
{
private:

int n;
public:
count()
{
n=0;
}

void show()
{
cout<<"n=  "<<n<<endl;
}

void operator ++ ()
{
n=n+1;
}
};

void main()
{
count c;
c.show();
c++; //or ++c
c.show();
getch();
}

1 comment:

  1. Thanks for shairng c+++ links see latest cells here:
    http://www.mobile-phone.pk/latest_mobiles/

    ReplyDelete