Writing a deep copy - copying pointer value

后端 未结 3 882
野趣味
野趣味 2021-02-06 01:02

In writing a copy constructor for a class that holds a pointer to dynamically allocated memory, I have a question.

How can I specify that I want the value of the pointer

3条回答
  •  有刺的猬
    2021-02-06 01:40

    I do not see the context, but the code you posted doesn't seem like copying the pointer, it is exactly what you ask for — copying whatever it points to. Provided that foo points to the allocated object.

提交回复
热议问题