const函数 [英] const functions

查看:74
本文介绍了const函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当一个类的函数成员声明为const时,它意味着什么?


谢谢


Pmb

What does it meant when a function member of a class is declared as const?

Thanks

Pmb

推荐答案



" Pmb" <所以***** @ somewhere.com>在消息中写道

新闻:X5 ******************** @ comcast.com ...

"Pmb" <so*****@somewhere.com> wrote in message
news:X5********************@comcast.com...
什么这是否意味着当一个类的函数成员声明为const?
What does it meant when a function member of a class is declared as const?




它不会修改调用它的对象。


john



That it does not modify the object on which it is called.

john




" Pmb" <所以***** @ somewhere.com>在消息中写道

新闻:X5 ******************** @ comcast.com ...

"Pmb" <so*****@somewhere.com> wrote in message
news:X5********************@comcast.com...
什么这是否意味着当一个类的函数成员被声明为const?
What does it meant when a function member of a class is declared as const?




首先检查FAQ。
http://www.parashift.com/c++-faq-lit .. .html#faq-18.10


Pmb写道:

当一个函数成员的意思是什么class被声明为const?

What does it meant when a function member of a class is declared as const?




该函数在调用时不会改变

对象的状态。


实际上这意味着:可以在const对象上调用此函数。

-

Karl Heinz Buchegger
kb ****** @ gascad.at


这篇关于const函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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