const关键字在编程中有什么好处? [英] What is the benefit of the const keyword in programming?

查看:113
本文介绍了const关键字在编程中有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
告诉我使用const正确性

Possible Duplicate:
Sell me on using const correctness

我很想知道答案. [转至"const关键字在编程中有什么好处?"

I'm eager to know the answer. [to "What is the benefit of const keyword in programming?"]

推荐答案

const 表示分配给变量的值不能更改.如果尝试更改该值,则会出现编译器错误.

const indicates that the value assigned to the variable cannot change. If you try to change the value you should get a compiler error.

这篇关于const关键字在编程中有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆