Hi all,
I'm having a problem with a program that continually generates assertion errors. After stepping through in the debugger and inserting several lines to track the progress, I've found it is attempting to call the class destructor 2 times more than it calls the class constructor. As a result, it's trying to delete[] memory that has never been allocated, and causing a problem.
I can make the problem go away by simply removing the delete[] statement from the destructor, but I know that's not right.
It's a textbook project on overloading operators, and I'm wondering if it's something to do with implicitly created temporary objects, but I would think the compiler would have to call the constructors when it created those temporary objects. It's not. I've basically copied the code directly out of the textbook, though changed the operations and types of course to suit the assignment, but the definitions and syntax is identical. All I changed was the meat of the functions, and that's not what's causing the problems.
I can post code if desired, but it's not short...
I'm having a problem with a program that continually generates assertion errors. After stepping through in the debugger and inserting several lines to track the progress, I've found it is attempting to call the class destructor 2 times more than it calls the class constructor. As a result, it's trying to delete[] memory that has never been allocated, and causing a problem.
I can make the problem go away by simply removing the delete[] statement from the destructor, but I know that's not right.
It's a textbook project on overloading operators, and I'm wondering if it's something to do with implicitly created temporary objects, but I would think the compiler would have to call the constructors when it created those temporary objects. It's not. I've basically copied the code directly out of the textbook, though changed the operations and types of course to suit the assignment, but the definitions and syntax is identical. All I changed was the meat of the functions, and that's not what's causing the problems.
I can post code if desired, but it's not short...
Comment