current position:Home>C + + may be caused by deep and shallow copy

C + + may be caused by deep and shallow copy

2022-02-03 01:44:59 CSDN Q & A


The code is as follows




I think I have a deep copy , Including deconstruction , Why are there still mistakes .
Do you have a brother to explain what the problem is , And how to solve it ?

Refer to the answer 1:

The allocation array is [], No ()

m_name = new char[strlen(name)+1];

Refer to the answer 2:

Refer to the answer 3:

It is suggested to have a look again new Usage of .

Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended