39

Here are two ways to initialize a variable in C++11:

T a {something};
T a = {something};

I tested these two in all scenarios I could think of and I failed to notice a difference. This answer suggests that there is a subtle difference between the two:

For variables I don't pay much attention between the T t = { init }; or T t { init }; styles, I find the difference to be minor and will at worst only result in a helpful compiler message about misusing an explicit constructor.

So, is there any difference between the two?

4

1 に答える 1