Thursday 31 May 2007

Const Correctness

I recently found a good article by Herb Sutter on Const-Correctness, a powerful feature of C++. This article talks about when to use const and when not to use it.

Const Correctness by Herb Sutter

Very interesting!

Thursday 24 May 2007

Resolving function address ...

The question is, if we are calling a function 'void function()' from 'main()', how the call is actually made?

We know the answer, it will be just a jump instruction to a particular address where the function instruction set starts.

How the member function address resolved in C++?

We all know member function is not stored as part of the class. It will be stored outside somewhere (code segment?). Then how is the call made when we say 'obj.function()'?

The answer is simple, actual call made would be like 'function(&obj)'. Thereby it will be just a simple jump instruction as we saw earlier.