Are destructors overloadable?

前端 未结 2 1434
北恋
北恋 2020-12-18 22:06

enable_if doc page says:

Constructors and destructors do not have a return type; an extra argument is the only option.

Are d

相关标签:
2条回答
  • 2020-12-18 22:47

    Are destructors overloadable?

    The answer is plain No.
    Two versions of desturctor cannot co-exist in a class body.

    However unlike the popular belief, note that destructor does have 2 syntax.

    struct E {
      ~E();  // syntax-1
      ~E() throw(); // syntax-2
    };
    

    Syntax-2 is less popular. But it is mandatory, if the base class destructor contains similar syntax. The best example is inheriting std::exception.

    Note that, not complying to such syntax results in:

    error: looser throw specifier for ‘virtual E::~E()’

    0 讨论(0)
  • 2020-12-18 23:04

    No


          

    0 讨论(0)
提交回复
热议问题