merge branch cpp OK!

This commit is contained in:
e0x2d 2025-02-27 22:35:29 +08:00
parent 946f5059d7
commit 9895e340ec

View File

@ -51,5 +51,22 @@ demo& demo::operator = (demo&&); // 移动赋值构造函数
`egg demo1 = egg::large;`
并且关闭了隐式转换的特性
## 友元
+ 友元函数
+ 友元类
+ 友元成员函数
将函数声明放在类体内,public private 内都无所谓
在声明前面加上friend关键字
explicit 禁止单个参数构造函数导致的自动类型转换
## 类的自动转换和强制类型转换
当类有仅一个参数的构造函数时
遇到合适的会进行自动转换
explicit 禁止单个参数构造函数导致的隐式自动类型转换
仍然可以使用显式强制转换(当不存在二义性时)
### 转换函数
`int aaa = int(demo);`
operator typeName();
+ 必须是类成员
+ 不能有参数
+ 不能指定返回类型