Here is the code:
#include <iostream>
class String
{
public:
    String() = default;
    String(const char* string)
    {
        printf("created\n");
        size = strlen(string);
        data = new char[size];
        memcpy(data, string, size);
    }
    ~String()
    {
        delete data;
    }
private:
    char* data = nullptr;
    size_t size = NULL;
};
class Entity
{
public:
    Entity(String name) :
        name(name)
    {
    }
private:
    String name;
};
int main()
{
    Entity entity("name");
}
It triggers a break-point in file delete_scalar.cpp
_CRT_SECURITYCRITICAL_ATTRIBUTE
void __CRTDECL operator delete(void* const block) noexcept
{
    #ifdef _DEBUG
    _free_dbg(block, _UNKNOWN_BLOCK);
    #else
    free(block);
    #endif //A cross sign here and says "learn.exe has triggered a breakpoint"
}
I copied the code from a video I was watching. He says the code does not work because a copy constructor is missing and goes on to write a copy constructor but does not explain why It does not work if the copy constructor is missing. I want to know exactly which part of the code triggers this breakpoint and why does the default copy constructor not suffice?
