TITLE: Parenthesis and declarations PROBLEM: sha@krym.equinox.gen.nz (Alex & Natasha Maclinovsky) #include class C { public: long l; C(long ll) { l = ll; } } static char ch = 33; int main() { C c1((long(ch))); C c2(long(ch)); // Problem here cout << c1.l << ' '; cout << c2.l; // Compilers give error here } last line of main() complaining something like "c2 - not a structure". It took us few hours to realise where the problem was: the stupid things instead of definition of saw a PROTOTYPE of a function called c2, which takes one argument of type long and returns an object of class C by value. Is it just a coincidence that 3 such a different compilers (which I'm sure have no common code) fail in exactly the same way? RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 11 Mar 95 Not exactly a coincidence, but a long-standing language rule. If a statment *can be* interpreted as a simple declaration, it *is* interpreted as a simple declaration. (For more details, see the ARM.) > C c2(long(ch)); // Problem here In a function declaration, redundant parens around dummy argument names are permitted, so this is equivalent to C c2(long ch); or just C c2(long); Thus, "c2" is a function , not an initialized object. > C c1((long(ch))); This cannot be a declaration of a function "C c1(long)", since the extra parens around "long(ch)" would not be allowed. Thus it must be a definition of object "c1" initialized with "ch" converted to long. You can avoid the problem by writing C c2( (long)ch ); // instead of "long(ch)" And of course in the particular example no cast is needed: C c2(ch); // implicit conversion of char to long But in a different example a cast might be necessary to avoid an ambiguous call to overloaded constructors.