I have a complex no class. I am trying to overload =.
I have pasted some code below
Q1. usually an = returns true or false if the assignment was successful or not
Is the code written below correct for such an overloading.
if it is not, what is the problem there.
Q2. = is recommended to be written as a class member. Can i however, write it as a non class function? How ?
Like I said, it shouldn't return a bool. It should return a reference to the object that called it. If the assignment fails, I guess you would need to throw an exception. Using a boolean return value is not recommended.
Like I said, it shouldn't return a bool. It should return a reference to the object that called it. If the assignment fails, I guess you would need to throw an exception. Using a boolean return value is not recommended.