Why would you use the keyword const if you already know variable should be
constant?
Many of the books that I am reading use keyword const when the value of a
variable should not be modified. Apart from specifying to readers of the
code that you may cause errors if you modify this variable (you can use
comments to do this), why would you need that keyword to be a part of any
programming language? It seems to me that if you don't want a variable
modified, simply don't.
Could someone clarify this for me?
No comments:
Post a Comment