C ++中的类型转换 [英] Type-casting in C++

查看:43
本文介绍了C ++中的类型转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这本书学习两个月的C ++:《使用C ++的编程原理和实践》,现在我想澄清一些关于我的转换的疑问.当我执行隐式转换时,例如:

I'm studying C++ by two months using the book : Programming principles and practice using C++, and now I wanted to clarify some doubts about my casting. When I am performing an implicit conversion, for example :

char c = 'a'; 
int b = c; 

此处,不使用任何显式运算符将c的值隐式转换为int类型.这算是演员吗?或仅在我必须执行像

Here the value of c is implicitly converted to int type without using any explicit operator. Is this considered casting ? or its considered casting just when I have to performe an explicit conversion like in :

int a = 10; 
int b = 5.5; 
double sum = double (a) / b; 

我知道这听起来可能是一个愚蠢的问题,但我只是想确定转换的问题.

I know it may sound a stupid question but I just wanted to be sure about conversions.

推荐答案

铸造"仅在执行显式转换时使用.

"Casting" is only when you perform an explicit conversion.

话虽如此,您会在整个互联网和各个团队中发现滥用的术语!

That being said, you will find the term misused all across the internet and in various teams!

这篇关于C ++中的类型转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆