Mostly fun stuff

Project maintained by theo-pnv Hosted on GitHub Pages — Theme by mattgraham

Knowledge base (C++)

- What’s the difference between NULL and nullptr?

NULL is an integer inherited from C (int i = NULL; is possible). nullptr is a self-defined type (int i = nullptr; is impossible) that can be converted to pointers but not integers. (Source)

- What’s a VTable?

Stands for Virtual Table and is built by the compiler for every class that contains virtual functions.

It stores a pointer to each virtual function’s definition (the most specific/overriden1 definition). When one calls a virtual method, we lookup the object’s VTable and call the appropriate derived class method.

A class defining virtual methods must always define a virtual destructor (with a body), or it leads to undefined behavior.