const修饰类成员函数
时间: 2024-01-07 20:04:01 浏览: 82
const修饰类成员函数的作用是表明在该成员函数中不能对类的任何成员变量进行修改。通过使用const修饰,编译器会隐含地修改该成员函数的this指针,使其类型变为const 类名* const this。这意味着在const成员函数中,this指针指向的对象是不可修改的。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [C++:类中const修饰的成员函数](https://blog.csdn.net/weixin_73470348/article/details/128761564)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [c++基础(十二)——const修饰成员函数](https://blog.csdn.net/qq_52302919/article/details/127129326)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文