static_cast
时间: 2023-06-28 10:05:53 浏览: 28
`static_cast` is a C++ type conversion operator that allows you to convert a value from one data type to another. It performs a compile-time conversion and is safer than a C-style cast because it only allows conversions that are known to be safe at compile-time.
Here's an example:
```
double d = 3.14;
int i = static_cast<int>(d); // convert double to int
```
In this example, `static_cast` is used to convert the `double` value `3.14` to an `int` value `3`.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)