Tuesday, 31 March 2015

Operator Return Values

When the member function of operator++ is returning any value, then it is said to operator returning value.

Sample Program

#include <iostream.h>
class index
{
int value;
public:
index(void)
{
value = 0;
}
int operator++(void)
{
value = value + 1;
return(value);
}
};
void main()
{
index A;
int x1, x2;
x1 = A++;
cout<<”X1 value is “<<x1;
x2 = ++A;
cout<<”X2 value is “<<x2;
}

No comments:

Post a Comment