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()**
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With