Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Wednesday, April 21, 2010

This program is used to overload operators in c++


This program is used to overload operators in c++
 
#include< iostream.h>
#include< conio.h>
class list
{
int count;
public:
//constructor for initializing the variable count to 0
list()
{
count=0;
}
//parametrized constructor for initializing the variable count
list(int i)
{
count=i;
}
// operator ++ overloaded
void operator ++()
{
++count;
}
//Function for displaying the value of count
void showdata()
{
cout< < count;
}
};
void main()
{
clrscr();
list l;
cout< < endl< < "C= ";
l.showdata();
//calling the overloaded operator
++l;
cout< < endl< < "C = ";
l.showdata();
}

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP