Advantages of Declaring a Constant Object as Const

By declaring a variable that doesn’t change throughout program’s execution as const, you make your code safer and more readable. But there’s an additional advantage: efficiency. An optimizing compiler can take advantage of a const object, and store it in a machine register instead of ordinary memory. Such optimization can sometimes boost up performance significantly.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: