I am building a bigint class and currently having an issue with overloading operators simple +, -, and * operators with my destructor. The bigint class contains a dynamically allocated array of int's. When my destructor is called, the dynamically allocated memory gets dissolved.
When overloading +, -, and *, I create a new bigint called answer which, obviously, holds the answer to the operations. My problem is that I return answer from the operator overloading functions, and at that point my destructor is automatically called and deletes the array I was trying to pass back as a part of the answer. This is causing me all sorts of trouble. Any ideas on how to fix it??
Thank You!!!!!
When overloading +, -, and *, I create a new bigint called answer which, obviously, holds the answer to the operations. My problem is that I return answer from the operator overloading functions, and at that point my destructor is automatically called and deletes the array I was trying to pass back as a part of the answer. This is causing me all sorts of trouble. Any ideas on how to fix it??
Thank You!!!!!
Comment