繁体   English   中英

差异b / w const int func(); 和int func()const;

[英]difference b/w const int func(); and int func() const;

我知道什么时候使用

int func() const;

那么除了可变变量之外,我们不能修改函数中的任何东西。 但是当我使用的时候

const int func();

它允许我修改任何东西?

const int func();

是返回const int和的const int

int func() const;

const函数,即不修改对象状态的函数,在该函数上调用它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM