#include<iostream.h> #include<conio.h> /*************************************************************************///------------------------------ counter ------------------------------///*************************************************************************/class counter { private: int count; public: counter() { count=0; } counter(intvalue) { count=value; } voidoperator++() { ++count; } voidoperator++(int) { count++; } void showdata() { cout<<count<<endl; } }; main( ) { clrscr(); counter obj1(2); counter obj2(6); counter obj3(9); cout<<"\n ********* Before Increment *********"<<endl; cout<<"\n Data of obj1 is = "; obj1.showdata(); cout<<"\n Data of obj2 is = "; obj2.showdata(); cout<<"\n Data of obj3 is = "; obj3.showdata(); ++obj1; obj2++; obj3++; cout<<"\n ********* After Increment *********"<<endl; cout<<"\n Data of obj1 is = "; obj1.showdata(); cout<<"\n Data of obj2 is = "; obj2.showdata(); cout<<"\n Data of obj3 is = "; obj3.showdata(); getch(); return 0; }
No comments:
Post a Comment