C++ and ANSI C
Henry Spencer
henry at utzoo.uucp
Sat May 6 03:27:54 AEST 1989
In article <3934 at tekcrl.LABS.TEK.COM> danw at tekchips.LABS.TEK.COM (Daniel E. Wilson) writes:
>> 1. "extern foo();" means (so to speak) "extern foo(...);" in ANSI C and
>> "extern foo(void);" in C++
>
> Number 1 is incorrect since C++ uses '...' to indicate that the number
>and type of arguments is unknown. The void keyword in ANSI C indicates
>that the function takes no arguments. No arguments in the prototype in
>C++ means that there are no arguments.
Uh, please read what I wrote: that's exactly what I said. Empty parens
mean "arguments unknown" in ANSI C (with the "so to speak" because the
usage of "..." in the above is not legal ANSI C) and "no arguments" in C++.
Using the void keyword in this manner is legal in C++ -- it's a synonym
for empty parens -- although it is officially described as an anachronism.
>> 2. declaring a struct or union tag in C++ essentially does an implicit
>> typedef on that identifier as well
>
> Number 2 is correct since the struct and union concepts in C++
>are subsets of the class concept. The class concept requires that
>a class be a new data type.
In retrospect, backward compatibility would have been much improved if
struct and union had been made subsets of the class concept *except*
for the implicit typedef. Then "class foo {" would still do the right
thing but "struct foo {" would still have its old meaning. Too late now...
--
Mars in 1980s: USSR, 2 tries, | Henry Spencer at U of Toronto Zoology
2 failures; USA, 0 tries. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list