   Var/Class init performance question
  Which is faster?1.) String myStr = "Foo";or2.) String myStr("Foo");Does the first method call the default constructor for String, and then the operator= operator? The second method I'm assuming just calls a copy constructor?   
  What language?In C++ the two generate identical code.   ;  Assuming C++, they are the exact same, both will call the one constructor that accepts a C-style string or some other type which accepts a C-style string.   ;  Yes I meant C++, sorry about the lack of info.Nice that they generate identical code. What about this?3.) String myStr; myStr = "Foo";Obviously this is a poor choice anyway because it could be done on one line, and it leaves 'myStr' uninitialized when it is created, which is bad.   ;  That will default construct myStr and then call the assignment operator. This will generally be slower than direct initialization.   