4

I am learning C++, and I've seen that all of the following examples initialize an int to a given value:

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

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

The only questions (and answers) I've found only:

  1. Deal with the first 2 examples.
  2. Mention that for "int" these may be the same, but for other types it may not be the same (without specifying how or why).

I'd like to further understand the difference between these, and how may they differ in other cases.

Community
  • 1
  • 1
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
  • `Obj obj1 = Obj(..)` requires a copy/move constructor. – Jarod42 May 15 '14 at 10:13
  • I've closed as duplicate because: 1) the first two are discussed in the link you have posted and many other questions. 2) the third one is the new C++11 uniform initialization syntax which is, also, been discussed innumerable times. If you think this is unfair, please, feel free to ping me. – Shoe May 15 '14 at 11:09

0 Answers0