且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

识别隐式转换和明确的转换

更新时间:2022-12-16 08:17:54

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

在这种情况下,有什么可以显式或隐式调用的转换的。这是可能是对这个问题的作者的意思,而是以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.