P
pallavsingh81
#include<iostream.h>
//prefix and postfix Operator overloading // Inorder to see effect
overload operator <<
class A
{
public :
int i,j;
A(int _i,int _j):i(_i),j(_j){}
A & operator++();
const A operator++(int);
};
A& A:
perator++()
{
this->i = this->i + 1;
this->j = this->j +1 ;
return *this;
}
const A A:
perator++(int)
{
A obj = *this;
this->i = this->i + 1;
this->j = this->j +1 ;
return obj;
}
ostream & operator << (ostream & out , A & obj)
{
out<<"Value of i "<<obj.i<<endl;
out<<"Value of j "<<obj.j<<endl;
return out;
}
int main()
{
A obj(10,20);
cout<<++obj;
cout<<obj++; // Error Why ????????????????
return 0;
}
//prefix and postfix Operator overloading // Inorder to see effect
overload operator <<
class A
{
public :
int i,j;
A(int _i,int _j):i(_i),j(_j){}
A & operator++();
const A operator++(int);
};
A& A:
{
this->i = this->i + 1;
this->j = this->j +1 ;
return *this;
}
const A A:
{
A obj = *this;
this->i = this->i + 1;
this->j = this->j +1 ;
return obj;
}
ostream & operator << (ostream & out , A & obj)
{
out<<"Value of i "<<obj.i<<endl;
out<<"Value of j "<<obj.j<<endl;
return out;
}
int main()
{
A obj(10,20);
cout<<++obj;
cout<<obj++; // Error Why ????????????????
return 0;
}