Are there any valid use cases to use new and delete, raw pointers or c-style arrays with modern C++?

前端 未结 19 927
梦谈多话
梦谈多话 2020-11-22 07:20

Here\'s a notable video (Stop teaching C) about that paradigm change to take in teaching the c++ language.

And an also notable blog post

19条回答
  •  忘了有多久
    2020-11-22 08:02

    You sometimes have to call new when using private constructors.

    Say you decide to have a private constructor for a type that is intended to be called by a friend factory or an explicit create method. You can call new inside this factory but make_unique won't work.

提交回复
热议问题