Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwvax!tank!eecae!shadooby!sharkey!mcf!mibte!gamma!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Any interest in making C++ a real superset of ANSI C? Message-ID: <9406@alice.UUCP> Date: 29 May 89 14:34:38 GMT References: <7435@hoptoad.uucp> <9395@alice.UUCP> <1989May28.235216.29243@utzoo.uucp> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 46 First of all, I should point out that I think the ability to have a struct with the same name as an object was put into C as a compatibility hack in the first place -- C did not always have structures and keeping their names separate from other names was a good way to avoid breaking existing code. Old habits die hard. Personally, I've always found things like struct A A; a little confusing. However, if you're trying to translate C programs that do this sort of thing into C++ programs, I think you will find that C++ 2.0 is a lot more compatible with C in this sense than previous versions. For example, the following is legal in 2.0: struct A { int a; }; extern void f(A); struct A A; // `struct' optional here main() { struct A b; // `struct' or `class' needed here A.a = 3; b = A; f(A); }; This works if `struct' is replaced by `class', too, provided that the definition of A is changed slightly: class A { public: int a; }; Otherwise A::a would be private and inaccessible to `main.' None of this introduces any new differences between `struct' and `class.' Instead, a class that does not have any constructors is considered to be enough like C that the C++ translator will go out of its way to allow C usages it would otherwise reject. -- --Andrew Koenig ark@europa.att.com