gpt4 book ai didi

c++ - const int function(); 之间的区别和 int func() 常量;

转载 作者:行者123 更新时间:2023-11-28 03:06:47 30 4
gpt4 key购买 nike

我知道什么时候用

 int func() const;

then we cannot modify anything in the function except for mutable variable.But when i used

const int func();

它允许我修改任何东西吗?

最佳答案

const int func();

是返回 const int

的函数
int func() const;

const 函数,即不修改对象状态的函数,它已被调用。

关于c++ - const int function(); 之间的区别和 int func() 常量;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19471098/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com