做类特定的新的删除操作符必须声明为static [英] Do the class specific new delete operators have to be declared static

查看:86
本文介绍了做类特定的新的删除操作符必须声明为static的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否需要在标准的类特定的新的,新的[],删除和删除[]是静态的。
我可以使它们成为非静态成员运算符。为什么它需要它们是静态的

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

推荐答案

是的,它是必需的,它们是静态的。它们用于为尚不存在的对象分配内存,因此没有要引用的实例。

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.

这篇关于做类特定的新的删除操作符必须声明为static的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆