C++ Virtual operator delete?

前端 未结 4 1518
没有蜡笔的小新
没有蜡笔的小新 2020-12-31 05:59

Is it possible to have a virtual delete operator? I\'m not talking destructor, I mean the actual operator overload.

Minus the fact that it is (in most cases) a big

4条回答
  •  感动是毒
    2020-12-31 06:28

    No - you can't have a virtual operator delete - class-specific new and delete overloads must be static member functions - specific to the class, not to the object.

    You can't have virtual static member functions.

    See section 12.5.7 of the standard, which states "Since member allocation and deallocation functions are static they cannot be virtual."

提交回复
热议问题