1

What are the differences between the following?

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

I have tried looking at the assembly of this and was hoping for any difference but i haven't found any. However my professor recommended me to ALWAYS use int i{value} for every initialization ever, no matter which type, the reasoning was because in a modern standard (i think C++17) it would always work, and the alternatives would have caveats.

Also in member initializer lists:

SomeClass::SomeClass(int a, int b): a(a), b{b} {}

() and {} seem interchangeable to me.

Tom
  • 134
  • 7

0 Answers0