C++-类与对象总结

const函数声明

  1. 修饰成员函数,不会改变成员变量:
  • a function b const (c){}: in member function means, all member properties in the function cannot be modified.

2.修饰形参,输入参数在函数中不会被更改,提高程序的健壮性:

  • a function b (const c){}: the parameter c cannot be modified in the function
  1. 修饰返回值,返回值不能修改,尤其用在返回值是指针类型的时候:
  • const a function b (c){}: the return value a cannot be modified in the function
相关推荐
大锦终几秒前
【Linux】Reactor
linux·运维·服务器·c++
星火飞码iFlyCode3 分钟前
iFlyCode+SpecKit应用:照片等比智能压缩功能实现
前端·javascript
星释9 分钟前
Rust 练习册 44:Trait 中的同名函数调用
开发语言·后端·rust
fanruitian11 分钟前
Java 静态代码块
java·开发语言
lly20240623 分钟前
SQL CREATE DATABASE
开发语言
朝九晚五ฺ33 分钟前
深入Rust标准库(std):核心能力与实战指南
开发语言·后端·rust
2013编程爱好者35 分钟前
Rust变量
开发语言·后端·rust
沐怡旸1 小时前
【穿越Effective C++】23.宁以non-member、non-friend替换member函数
c++·面试
star learning white1 小时前
xmC语言8
c语言·开发语言·算法
一只爱学习的小鱼儿1 小时前
QT中3D的使用
开发语言·数据库·qt