Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!rutgers!cs.utexas.edu!pp!riunite!rfg From: rfg@riunite.ACA.MCC.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: More nits to pick at... Message-ID: <190@riunite.ACA.MCC.COM> Date: 1 May 89 15:23:39 GMT Reply-To: rfg@riunite.UUCP (Ron Guilmette) Organization: MCC Austin, Texas Lines: 189 Listen friends... Is it just me or is this language difficult to understand and/or not rigidly specified at this time? (Actually, I already know the answer. That is just my way of trying to excuse myself for pestering you all with all of my nit picking questions. I hope that I will be forgiven if I occasionally break into the middle of these Socratic discussions of the true meaning of "polymorphism" to ask some rather more mundane questions about C++ which the poor schmucks down in the trenches {like me} may need to know about.) So here is edition #2 of my nit picking questions. I hope that even the language lawyers will find at least one brain teaser in here. As before, I would welcome *any* responses from *anybody* who feels that they may have a handle on how things really are (or better yet how they should be, or how they will be when "2.0: The Movie" arrives for your Summer (Ahem... Fall? ... Winter?) viewing pleasure.) :-) ----------------------------------------------------------------------- How can you declare a function which can accept a pointer to itself as an argument (in a type-safe manner of course)? You can now inherit a base class as either public or private. Can you inherit a base class as "protected"? If so, what does this mean? Is it legal to declare an operator which takes no struct/class parameters but which does take at least one union parameter? At least one enum parameter? Is it an error if there is either an implicit or an explicit call to a constructor (or a destructor) for a given class at a point where the given constructor (or destructor) is not "visible" because it is either private or protected? If a constructor makes calls to virtual member functions which are declared (and defined) for the constructor's own class, do these calls ever go through the virtual function table? If so why? Is there any way to specify (explicitly) the order in which members and base classes are destructed? Is it legal to declare a function as inline and later give either another declaration or a definition for the function whose heading does *not* include the keyword "inline"? Is it legal to declare a function as non-inline and later to redeclare it (or give a definition for it) which is inline? Is it legal for a member function to be both inline and virtual? If so, should the "inline" keyword come before or after the "virtual" keyword? Are enum type values always treated like int type values or can they be used to disambiguate a function call, i.e.: enum color { red, yellow }; enum fruit { banana, apple, orange }; void overloaded (enum color); void overloaded (enum fruit); void overloaded (int i); ... overloaded (red); overloaded (apple); overloaded (99); ... At the end of section 8.9 in the reference manual there is a short note about how to get the address of a particular instance of an overloaded function. It says: "The address-of-operator & may only be applied to an overloaded name in an assignment or initialization where the type expected determines which function to take the address of." Here, the term "the type expected" is not really defined. It is thus, not clear (as it is in the definition of the Ada language) what elements of the context may (or may not) be considered when a "standard conforming" compiler attempts to perform disambiguation. Specifically, I would like to know if the following should be considered legal (i.e. unambiguous): class A { ... }; class B { ... }; void overloaded (A); void overloaded (B); void* pointer = (void (*)(A)) &overloaded; What are "static member functions"? I seem to recall seeing something which related this term somehow to "operator new" and "operator delete" members. Are these two (special?) operator members implicitly static? Do "static" member functions (and operators) lack a "this" pointer? If so, is it an error to refer to "this" within the body of such operators. May a default argument be a non-constant expression? May an expression supplied as a default function argument contain a reference to: a) the "this" pointer (for member functions), or b) earlier parameters in the same parameter list, or c) later parameters in the same parameter list, or d) the address of the function for which the formal parameter list is being specified? Are default argument expressions compile-time evaluated in the context of the default argument expressions themselves, or are they compile-time evaluated in the context of each individual call in which they are used? For instance, will the following print 3 or 7? const int k = 3; int f (int i = k) { printf ("%d\n", i); } int main () { const int k = 7; f (); } Is it legal or illegal to put an "overload" statement inside a function? Inside a class? A struct? A union? Is it ever of any value to nest overload statements within these contexts? Is the following legal? overload x; overload x; overload x; Is the following legal? Is it ever required? overload operator+; Is the following legal? class base { public: overload member; void member (); void member (int i); }; Is the following legal? int global_item; overload global_item; void global_item (int i); Is there any possible ordering of the three statements above which would be considered legal? Is it ever legal to specify a return type for either a constructor or a destructor? Specifically, is it legal for constructors and/or destructors to return (a) void, or (b) void*, or (c) class_type*, where "class_type" is the name of the containing class? Is it legal or illegal to place a declaration for a member function within one "visibility section" (i.e. "public", "private", or "protected") of a class declaration and then to subsequently re-declare the same member function (with the same parameter list) in a different "visibility section" of the same class declaration, for example: class base { protected: void member (int i); public: void member (int i); // legal ? private: void member (int i) {} // legal ?? }; ------------------------------------------------------------------------------- -- // Ron Guilmette - MCC - Experimental Systems Kit Project // 3500 West Balcones Center Drive, Austin, TX 78759 - (512)338-3740 // ARPA: rfg@mcc.com // UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg