Search code examples
c++visual-c++clionvirtual-functionspure-virtual

pure virtual destructors in c++ Clion and VS2019


I'm trying do declare pure virtual destructor, in VS2019 I'm writing like that:

    virtual ~A() = 0 {};

and it's fine, but in Clion don't accept that I'm getting the following message:

pure-specifier on function-definition virtual ~A() = 0{ };

and it forces me to write a different implementation for the function (not that it to much trouble but id like to know why is that)


Solution

  • From the C++ 20 (11.6.3 Abstract classes)

    1. ...[Note: A function declaration cannot provide both a pure-specifier and a definition — end note] [Example:
    struct C {
      virtual void f() = 0 { }; // ill-formed
    };
    

    — end example]