-2

I am a Java developer who has recently gotten into c++. I've read several times that the new operator should be avoided as variables declared with it must be manually deleted. But then my question becomes: why should I ever use it?

G L
  • 673
  • 1
  • 4
  • 7

1 Answers1

0

First, read this

You can use 'placement' new which allows you to take a chunk of memory and write the object onto it. This is the only case I've ever had to use new since smart pointers became a thing.

Water
  • 2,369
  • 2
  • 20
  • 44