Isn't that fading away?

If i do

double d = 34.56;
int i = (int)d;

Am I really not "lowering"?

OR

Is this term used only in terms of classes and objects?


I am confused because in this case we “lower” from larger doubleto smaller int, but in the case of classes we “lower” from smaller base classto larger derived class.

Are these two conventions in a sense not opposed?

+3
source share
5 answers

No, you are not dumping. You are just casting, and you chop off something after the decimal.

. int double ++ , . .

, . . , .

+3

Downcasting - .

http://en.wikipedia.org/wiki/Downcasting

, , double int .

+7

int double , , .

, "" "" ( ), "", ""

0

, . , , , .

- dynamic_cast ( ) , - , ' () (- ) . , , - (.. ).

0

- . .

-1
source

Source: https://habr.com/ru/post/1743050/


All Articles