i have a certain problem regarding operator overloading function ....when i implement the overloading functions as friend functions i get the same
INTERNAL COMPILER ERROR ...what does that mean??? the program is free of syntax errors...but it is not working. How can i solve this problem??
the program...
Code:
#include <iostream>
using namespace std;
class s1
{
friend s1 operator+(int ,const s1 &);
public:
s1() { x=9; y=3; }
s1( int i) {x=i; y=7; }
s1( int i, int j) { x=i; y=j; }
void print() { cout<<x<<" "<<y<<endl; }
s1 operator+(const s1 &k) const
{
s1 M;
M.x=this->x+k.x;
M.y=this->x+k.y;
return M;
}
private:
int x, y;
};
s1 operator+(int x,const s1 &A )
{
s1 F;
F.x=A.x+x;
F.y=A.y+x;
return F;
}
void main()
{
s1 T, T2(5), T3(-1, 4);
T.print(); T2.print(); T3.print();
T=T2+T3;
T.print();
s1 T4=5+T3;
T.print();
T2.print();
T3.print();
T4.print();
}
//note: when i implement the operator overloading function as member function the program runs smoothly.