Overloading assignment operator
Hi everyone, I'm writing a part of my program that compares three objects of class IntArray:
Code:
IntArray IntArray::operator=(IntArray h){
if (len != h.len){
hault();
}
else {
IntArray temp(len);
for (int i = 0; i <= len; i++){
temp.arr[i] = h.arr[i];
}
return temp;
}
}
I overloaded the assignment operator so that the arrays within each class object can be compared. It works perfectly when comparing two classes (a = b), however when I try comparing three (a = b = c) the program gives me an unhandled exception error. I think it might have something to do with memory allocation?
Thanks for any help! Let me know if you need to see the rest of my program...
-Ryan