Detailed explanation of const usage in c++