C++ compiler structures such as Virtual method Table etc

c

I am aware of the C++ Virtual Table which allows dynamic dispatch for doing things at runtime (although if I am honest I am not completely sure of the full list of things it achieves).

I am wondering what other "low level" aspects of C++ are there, which one doesnt usually come across when learning the C++ language?

Things like:

-How is multithreading and locking on objects performed?

-Overloading/overwriting functions

-Generics

Are there other "structures", similar to the vtable, which assist with these types of things on a lower level?

(and if anyone can help with what the VTable actually does it would be most appreciated!)

Best Answer

Virtual Table

I would guess that the most official description of virtual tables would be found in chapter 10 of The Annotated C++ Reference Manual (sometimes called ARM) by Margaret Ellis and Bjarne Stroustrup. My copy is copyright 1990, not sure if that is the latest edition.

There are probably simpler, more graphic descriptions like

http://www.learncpp.com/cpp-tutorial/125-the-virtual-table/

or right here on Stack Exchange:

https://stackoverflow.com/questions/2173493/virtual-table-c

How is multithreading and locking on objects

I think this is not part of the original language.

p-threads (POSIX Threads) are a typical way to augment the language with a library and are supported on UNIX, Linux, and other operating systems including, surprisingly enough, even Windows.

Another library that supports threads is Boost. I read somewhere than some of the Boost threading support was adopted by the C++ standards committee and appears in C++11.

C++11 supports threads in an update to the standard library. There is also a notion of thread local storage that is described briefly from the same reference.

Overloading/overwriting functions

Chapter 13 of the ARM discusses this topic.

Generics

In C++ this would be templates.

Check chapter 14 of the ARM.

Related Topic