Is there a rule of thumb to decide when to use the old syntax ()
instead of the new syntax {}
?
To initialize
Take a look at this:
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=453&rll=1
The use of a {}
-style initializers on a variable has no direct mapping to the initialization lists on any constructors of the class. Those constructor initialization lists can be added/removed/modified without breaking existing callers.
Basically the different behavior of the container is special, and requires special code in that container, specifically a constructor taking a std::initializer_list
. For POD and simple objects, you can use {}
and ()
interchangeably.