[英]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.