Operator Overloading Problem

I have overloaded the operator + to add two objects of the class I have created.
This is the snippet of the code I have written
friend Polynomial& operator+(const Polynomial& p1,const Polynomial& p2) {
int i=0,j=0,k=0;
Polynomial p3(0);
int u = p1.members[0];
if(p1.members[i] > p2.members[j])
The Polynomial class has a variable which is an array. It goes like this

int members[26];

And I am trying to add two polynomials in my main fucntion

Polynomial p1;
Polynomial p2;
Polynomial p3(00;
p3 = p1+p2;

When I do this the program crashes. I turned the debugger on and checked where it is crashing. I found out that the line
int u = p1.members[0];
is returning a junk value. Or for that matter, any access to p1 or p2 in my overloaded function is crashing the program.
I have no clue why this is happening. Any pointers would be appreciated.

Did you initialize the members array in the constructor?
Topic archived. No new replies allowed.