Getting the redefinition error for virtual destructor

c++

Solution

Simply use the following in your class

virtual ~A();

instead of

virtual ~A()
             {
              }

The compiler is actually telling you exactly what the problem is here. You have two implementations - one inline in your class and another outside it here

A::~A()
{

}

you cannot have both.

Problem

I've the following C++ snippet: ``` #include <iostream> using namespace std; class A { public: virtual ~A() { } }; A::~A() { } int main(int argc, char * argv []) { return 0; } ``` Why am I getting these errors?: error: redefinition of 'A::~A()' A::~A() error: 'virtual A::~A()' previously defined here ``` virtual ~A()** ```

Original source