Wat said:
Is it doable to have a abstract class derived from a concrete class?
Yes.
Is it a good practice?
IMHO, no.
If so in what situation is this necessary?
Thanks in advance!
If you want a mix of concrete and abstract behavior you can start with the
abstract and then derive a base class with a partial implementation:
class Thing // abstract base class
{
public:
virtual const char *name() const = 0;
virtual do_something() = 0;
};
class Base : public Thing // partial implementation
{
private:
std::string m_name;
public:
Base(const char *i_name) : m_name(i_name) {}
virtual const char *name() const {return m_name.c_str();}
};
Now the client can derive from Base if he wants this implementation of
name() but can also derive from Thing if he wants to do it some other way.
If you derived Thing from a concrete type the concrete part would not be
negotiable.