I had a constructor in my AB.h file:
class AB{
private: int i;
public:
AB:i(0){}//constructor
~AB:i(0){} // destructor
virtual void methodA(unsigned int value)=0;};
The compiler said that:
class AB has virtual functions but non-virtual destructor
AB.h: In destructor ‘AB::~AB()’:
AC.h: error: only constructors take base initializers
if I use the ~AB(); destructor, it said that i have virtual functions but i didn’t have destructor, where did I misunderstand?
Thankyou
You’re getting an error and an unrelated warning.
The error is because you’re using an initializer for your destructor, which doesn’t make sense and isn’t valid syntax.
You want:
The warning is because you haven’t declared your destructor virtual. Classes with virtual methods should have virtual destructors: