如何const关键字工作在C [英] how const keyword works in c

查看:88
本文介绍了如何const关键字工作在C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解一下C和C ++常量内部。编译器如何规定constantness?
可有一个人帮我请。

I want to know about const internals in c and c++ . How compiler imposes constantness ? Can some one help me please.

推荐答案

在一般常量 100%的编译器。当你声明的东西常量,编译的放在什么会让你写的限制。它不会让你分配给const的标量,通过一个const引用或或指针赋值,或者调用const对象的非const函数。

In general const is 100% compiler. When you declare something const, the compiler places restrictions on what it will let you write. It won't let you assign to const scalar, assign through a const reference or or pointer, or invoke a non-const function of const object.

有没有保证,编译器会安排任何形式的运行保障。

There is no guarantee that the compiler will arrange any sort of runtime protection.

这篇关于如何const关键字工作在C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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