Troubleshooting: Debug Assertion Failed : _CrtIsValidHeapPointer(block) in C++

Опубликовано: 28 Октябрь 2024
на канале: Improve Your Programming skills
3,049
10

I have a class A containing a pointer.
I allocate that pointer in the constructor and destroy it in the destructor
In main() function, I create 2 objects a1, a2 and add a line of code a1 = a2.
main() {
A a1;
A a2;
a1 = a2;
}
Compile and run it then the program crashes :
(Debug Assertion Failed : _CrtIsValidHeapPointer(block)).
What's the matter? How to solve this problem?