Use-cases of pure virtual functions with body?

The classic is a pure virtual destructor: class abstract { public: virtual ~abstract() = 0; }; abstract::~abstract() {} You make it pure because there’s nothing else to make so, and you want the class to be abstract, but you have to provide an implementation nevertheless, because the derived classes’ destructors call yours explicitly. Yeah, I … Read more

Mechanism of Vptr and Vtable in C++

Just went through this link virtual table and _vptr It says that the workflow will be like .. base_ptr->base_vptr—-> to check the access of virtual function in base class. base_ptr->derived_vptr->virtual_function()—> to call/invoke the virtual function. Hence the derived class virtual function is called.. Hope you find it helpful.

Object oriented programming in Haskell

You just don’t want to do that, don’t even start. OO sure has its merits, but “classic examples” like your C++ one are almost always contrived structures designed to hammer the paradigm into undergraduate students’ brains so they won’t start complaining about how stupid the languages are they’re supposed to use†. The idea seems basically … Read more