I have a non-obvious to me question for anyone. I'm trying to inherit form an abstract base class, here's an example of the scenario I'm currently trying to wrap my head around:
AbstractMemoryPool.h
Code: Select all
#ifndef _ABSTRACTMEMORYPOOL_H_
#define _ABSTRACTMEMORYPOOL_H_
class AbstractMemoryPool
{
public:
virtual ~AbstractMemoryPool() { int j = 5; };
virtual void whatevs() = 0;
};
#endif
Code: Select all
#ifndef _PARTICLEMEMORYPOOL_H_
#define _PARTICLEMEMORYPOOL_H_
#include "AbstractMemoryPool.h"
class ParticleMemoryPool : public AbstractMemoryPool
{
public:
ParticleMemoryPool(void);
virtual ~ParticleMemoryPool(void);
virtual void whatevs();
};
#endif
Code: Select all
#include "ParticleMemoryPool.h"
ParticleMemoryPool::ParticleMemoryPool(void)
{
}
ParticleMemoryPool::~ParticleMemoryPool(void)
{
}
void ParticleMemoryPool::whatevs()
{
}
However noting the virtual destructor
Code: Select all
virtual ~AbstractMemoryPool() { int j = 5; };
This
Code: Select all
virtual ~AbstractMemoryPool();
Code: Select all
virtual ~AbstractMemoryPool() = 0;
Of course theres no implementation of the destructor, I just want to define an interface in AbstractMemoryPool.h.
Why if I do not provide an inline body for the virtual destructor of AbstractMemoryPool does the linker bitch?
I explicitely override the virtual destructor in ParticleMemoryPool.cpp