-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?

2

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.