-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
  • 833
  • 1
  • 6
  • 10

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
  • 3,245
  • 3
  • 28
  • 58