dimanche 31 mai 2015

Variable initialization guidelines in C++

Which are the guidelines to initialize variables in C++? There are so many ways to initialize a variable in C++. 3 ways with which I am familiar are as following:

1) int a=3;

2) int a(3);

3) int a{3}; // valid for C++11 & later

Which is the best approach? Why 2nd way int a(3); not seen & not used in C++ programs?
Thanks.

Aucun commentaire:

Enregistrer un commentaire