I have doubt in complex number class

how can we implement
complex a,b,c’
a=b+c

@tejasddongare hey for that you have to overload + operator for complex class which return ans as objcet and store that ans in anothere object here in your example its a.

sir my doubt is suppose we wrote a function for with overloading + operator than it will return addition of new complex no but if we return it wont the?stack memory of that overloading function will delete after terminating which will result in even deleting the copy of that complex object isnt it??

sir my question exactly is suppose we create a new object inside the function which has + overloading operator and after updating the value in a new object if we returned the object wont the class will call the destructor after terminating the operator+ function which may result in even deleteing the constructor object isnt it??? before returning or even after returning isnt it?

@tejasddongare hey you are right after function block finish the destructor will called for that object also , but return type of function is object which will return a temporary object which is stored in a.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.