TITLE: function versus variable declarations PROBLEM: [unknown author] ofstream outfile(); [...] How would you declare a function that returns an oftsream by value, takes no argument and is called `outfile'? [...] RESPONSE: esap@cs.tut.fi (Pulkkinen Esa) ofstream outfile(void); I've made this error many times. The confusion is mainly due to the constructor call syntax - they look too much like "unnamed" declarations: declaration constructor call for unnamed object (1) string a("foo"); string("foo") (2) string a(); ??? (3) string a; string() It's very easy to think that because in (1) the declaration and conversion look similar, it would also in (2) and (3). RESPONSE: kanze@gabi-soft.fr (J. Kanze), 22 Feb 96 It's worse that that: string a( "foo" ) ; // Declaration of a variable a, type string, init'ed with "foo" string a() ; // Declaration of a function a, no args, returning string char arr[] = "foo" ; string a( string( arr ) ) ; // Declaration of a function a, 1 arg of type string, returning // string!! I've never had any problem with the second form; just don't use unnecessary parentheses. On the other hand, I've yet to meet anyone with a little experience who hasn't been bitten by the last. To avoid it: string a = string( arr ) ; // No good if string doesn't have a copy constructor string a( (string)( arr ) ) ; string a( static_cast< string >( arr ) ) ; I generally prefer the second, and have adapted the rule of systematically putting the type name in parentheses for explicit constructor calls with one argument. The first is fine in this case, but typically, the problem hits you in more complicated cases, and sometimes, the object being constructed will not have an accessible copy constructor, making the = form of initialization illegal.