Sample Program
#include <iostream.h>
class inc
{
int val;
public:
inc(void)
{
val = 1;
}
void operator++(void)
{
val = val + 1;
}
void display(void)
{
cout<<val;
}
};
void main()
{
inc A;
A.display();
A++;
A.display();
++A;
A.display();
}
#include <iostream.h>
class inc
{
int val;
public:
inc(void)
{
val = 1;
}
void operator++(void)
{
val = val + 1;
}
void display(void)
{
cout<<val;
}
};
void main()
{
inc A;
A.display();
A++;
A.display();
++A;
A.display();
}
No comments:
Post a Comment