I have an abstract class, which i’m inheriting from.
To make it clear- I implemented all of the abstract methods in the inheritor.
After done using the object made from the inheritor class, im trying to destruct it, but instead of calling the inherited destructor it sends me to the abstract method.
in my programm it look like this
class LinkedHash {
private:
LinkedHashEntry **table;
int max_size;
public:
/* Creates a hashtable of size maxSize*/
LinkedHash(int);
LinkedHash(){}
/* deletes all members of the hashtable */
virtual ~LinkedHash();
virtual int hashFunction(int key) = 0;
void insert(int key, Process* value);
void remove(int key);
int getMaxSize(){return max_size;}
LinkedHashEntry* search(int x);
};
class LinkedHashinheritor: public LinkedHash {
public:
LinkedHashinheritor():LinkedHash(1000){}
int hashFunction(int key);
};
this is my cpp file relevant code:
int LinkedHashinheritor::hashFunction(int key)
{
return key%1000;
}
and there are the calling for constructor and destructor for the relevant object:
Scheduler::Scheduler()
{tmp_lh=new LinkedHashinheritor();}
Scheduler::~Scheduler()
{
delete tmp_lh;
}
To make this clear upfront: Making a class abstract does not prevent its destroctor from being called. The destructors of all classes in an inheritance hierarchy will always be called (in the order from derived class to base class).
As you have not declared a destructor in your derived class, and the compiler-provided one is extremely trivial (as in, it only has to call the destructor from the base class), it is very well possible that the compiler has optimised the derived destructor away.