Menu

Custom Search

C++ lab Program

#include
#include
class counter
{
int count;
public:counter(int a=0):count(a){};
counter operator ++(){
counter temp=++count;
return temp;} //return an objects of counter using temp. objects
counter operator --(){
return counter( --count);} //return nameless objects of counter
void display(){
cout<<"The value of count is:"< };
void main()
{
clrscr();
counter d(10);
d.display();
++d;
d.display();
counter d1=--d;
d1.display();
getch();
}

/* OUTPUT
The value of count is:100
The value of count is:101
The value of count is:100 */

No comments:

Post a Comment