Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do the class specific new delete operators have to be declared static

Tags:

c++

Is it required in standard for class specific new, new[], delete, and delete[] to be static. Can i make them non-static member operators. And why is it required for them to be static

like image 444
Yogesh Arora Avatar asked Jan 26 '10 17:01

Yogesh Arora


2 Answers

They are declared static implicitly -- even if you didn't type "static".

like image 111
Alexander Poluektov Avatar answered Oct 06 '22 00:10

Alexander Poluektov


Yes it's required for them to be static. They are used to allocate memory for an object that does not yet exist hence there is no instance to refer to.

like image 32
JaredPar Avatar answered Oct 06 '22 01:10

JaredPar