CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    1,342

    Declaring derived class destructor virtual

    I know it is only necessary to declare a method as virtual in the base class, and the overridden version in the derived class will automatically be virtual.

    Does this apply to destructors as well? In other words, is it necessary to declare the destructors of all non-leaf classes in an inheritance hierarchy virtual, or just the base class?
    Old Unix programmers never die, they just mv to /dev/null

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Declaring derived class destructor virtual

    Yes, it does, so declaring the derived class destructor virtual is unnecessary, but good practice.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured