Different ways to initialize an object in C ++

I am learning C ++ and I have seen that all of the following examples initialize an int for a given value:

int i = 0;
int j = int(0);
int k{ 0 };

I read other questions like int a = 0 and int a (0) differences [duplicate]

The only questions (and answers) that I found only:

  • Follow the first two examples.
  • Mention that for "int" they can be the same, but for other types it may not be the same (without indicating how and why).

I would like to further understand the difference between them and how they may differ in other cases.

+4
source share

No one has answered this question yet.

See similar questions:

:

4247
++
3076
++?
2583
2116
, ?
826
,
414
++?

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


All Articles