Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:00:05+00:00 2026-06-16T01:00:05+00:00

Is it possible to have a virtual delete operator? I’m not talking destructor, I

  • 0

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 bad idea to overload new and delete (Yes, I already know it’s heresy), I want to know what kind of implications come from using a virtual delete operator.

I’m thinking about trying to use a virtual delete, as sometimes I might have a child class that overloads delete, stored in a base class pointer. Technically, I don’t really ever see this case coming to too much fruition, unless I have a tree of different node types (potentially dangerous idea in the first place if you ask me).

I just want to know what would be the potential pros and cons of a virtual, or non virtual, delete operator override.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:00:07+00:00Added an answer on June 16, 2026 at 1:00 am

    You can’t explicitly declare operator delete as virtual.

    It is a static member function, even if you do not supply the keyword static.

    But operator delete is already virtual in the sense that the one defined in the most derived class is used. You might choose to think of it as if it’s called by the destructor. It might even be. 😉


    C++11 §12.4/12:
    “At the point of definition of a virtual destructor (including an implicit definition (12.8)), the non-array
    deallocation function is looked up in the scope of the destructor’s class (10.2), and, if no declaration is
    found, the function is looked up in the global scope.”


    C++11 §12.5/4:
    “If a delete-expression begins with a unary :: operator, the deallocation function’s name is looked up in
    global scope. Otherwise, if the delete-expression is used to deallocate a class object whose static type has
    a virtual destructor, the deallocation function is the one selected at the point of definition of the dynamic
    type’s virtual destructor (12.4).117 Otherwise, if the delete-expression is used to deallocate an object of
    class T or array thereof, the static and dynamic types of the object shall be identical and the deallocation
    function’s name is looked up in the scope of T. If this lookup fails to find the name, the name is looked up in
    the global scope. If the result of the lookup is ambiguous or inaccessible, or if the lookup selects a placement
    deallocation function, the program is ill-formed.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: C++ static virtual members? Can we have a static virtual functions? If
Possible Duplicate: c++ virtual function return type I have a simple but confusing question
Is it possible to have a free iPhone app that has say an initial
I currently have a virtual dedicated server through Media Temple that I use to
Is it possible to have a generic web api that will support any model
Possible Duplicate: Pure virtual destructor in C++ class A{ public: virtual ~A()=0; }; class
Is it possible to have inheritance with no virtual methods? The compiler is saying
Is it possible to have a virtual/abstract field in a C# class? If so,
Is it possible in C++ to have a class override a virtual function, but
is there any option to have Virtual COM port Host on Android that would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.