In your operator +=
function, you create a local CNode
called c_new
that you link into your linked list. When the scope ends (which happens before the function returns), that local is destructed, leaving the list dangling (pointing at a no longer valid CNode
, whose memory is about to be reused for some other local variable, such as the next c_new
created on the next call to the function).
Using/accessing an object after it has gone out of scope and been destroyed is undefined behavior, so will generally crash or otherwise misbehave.