c++ - Is it good habit to always initialize objects with {}? -
initializing objects new {} syntax this: int { 123 }; has benefit - not declare function instead of creating variable mistake. heard should habit that. see happen: // want create vector 5 ones in it: std::vector<int> vi{ 5, 1 }; // ups have vector 5 , 1. is habit then? there way avoid such problems? frankly, subtleties of various initialization techniques make difficult 1 practice "good habit." as mentioned in comment, scott meyers discusses brace-initialization @ length in modern effective c++ . has made further comments on matter on blog, instance here , here . in second post, says explicitly thinks morass of c++ initialization vagaries bad language design. as mentioned in 101010's answer, there benefits brace-initialization. prevention of implicit narrowing main benefit, in opinion. "most vexing parse" issue of course genuine benefit, it's paltry--it seems me in cases incorrect int a(); instead of int a; caught @ compile ...