识别隐式转换和明确的转换 [英] Identify the implicit cast and explicit cast

查看:150
本文介绍了识别隐式转换和明确的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想AP preciate它,如果任何人都可以回答我的问题。结果
识别隐式转换和明确的转换?

  int类型的= 2,B = 3;浮动F = 2.5;
双D = -1.2;
INT INT_RESULT;
浮REAL_RESULT;


解决方案

从形式上看,这个问题是没有从视图中的术语一点感觉。还有如隐式转换没有这样的事。术语的的整点是,它指定一个明确的,要求的转换的。演员是由(类型)形式的运营商明确要求的类型转换。

在这种情况下,有什么可以显式或隐式调用的转换的。这是可能是对这个问题的作者的意思,而是以C语言术语的知识贫乏搞砸了。

在您的code样品只有一个初始化需要一个转换。并且,当然,转换隐式的,因为没有的投射在你的code任何

I would appreciate it if anyone can answer my question.
Identify the implicit cast and explicit cast?

int a = 2, b = 3;

float f = 2.5;
double d = -1.2;
int int_result;
float real_result;

解决方案

Formally, the question makes no sense from the terminological point of view. There's no such thing as "implicit cast". The whole point of the term cast is that it designates an explicitly-requested conversion. Cast is the type conversion explicitly requested by the operator of the (type) form.

What in this case can be explicit or implicit is called conversion. This is what was probably meant by the author of the question, but screwed up by their poor knowledge of C terminology.

In your code sample only one initialization requires a conversion. And, of course, that conversion is implicit, since there are no casts in your code whatsoever.

这篇关于识别隐式转换和明确的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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