Reputation: 283
I have seen here and here that a good rule of thumb is to use virtual destructors for every class that is intended as a base class. I have a pure abstract base class (only contains pure virtual functions and no data members; intended to be used as an interface).
class A {
public:
virtual void foo() = 0;
};
Is it possible to add a virtual destructor to this class without creating an implementation file (this class is defined in a header file included in several .cpp files) just for an empty destructor while also avoiding clang and g++ warnings such as -Wweak-vtables? I cannot put the empty definition in the header file with the pure abstract class because I will get multiple definitions of the destructor.
Upvotes: 0
Views: 572