Is that the \0 character? I thought that was automatically added in?
It is automatically copied by strcpy, but it's not included as part of the length.
Example: strlen( "foo" );
This will give you 3, but the string "foo" actually consumes 4 bytes of memory (3 for the 'foo' and an extra 1 for the null terminator.
As a result...
1 2
Text first("line 1"); // this is allocating 6 bytes of memory... but then copying 7 bytes to that memory.
// So you are going out of bounds. Hence the heap corruption.
Also... DO NOT CALL DESTRUCTORS EXPLICITLY
1 2 3 4
int main()
{
Text first("line 1");
first.~Text(); // BAD BAD BAD
Destructors are called automatically! That's the whole point. By doing this you're calling the dtor twice which is very dangerous.