Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!panix!feed1.news.erols.com!news-xfer.netaxs.com!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!news.idt.net!news.cerf.net!nic.cerf.net!mpcline From: mpcline@nic.cerf.net (Marshall Cline) Newsgroups: comp.lang.c++,comp.answers,news.answers Subject: C++ FAQ (part 1 of 7) Followup-To: comp.lang.c++ Date: 17 Jan 1997 19:03:58 GMT Organization: Paradigm Shift, Inc (technology consulting) Lines: 1116 Sender: cline@parashift.com Approved: news-answers-request@MIT.EDU Distribution: world Expires: +1 month Message-ID: <5boieu$lq2@news.cerf.net> Reply-To: cline@parashift.com (Marshall Cline) NNTP-Posting-Host: nic.cerf.net Summary: Please read this before posting to comp.lang.c++ Xref: senator-bedfellow.mit.edu comp.lang.c++:236353 comp.answers:23758 news.answers:92398 Archive-name: C++-faq/part1 Posting-Frequency: monthly Last-modified: Jan 1, 1997 URL: http://www.cerfnet.com/~mpcline/c++-faq-lite/ AUTHOR: Marshall Cline / cline@parashift.com / Paradigm Shift, Inc. / One Park St. / Norwood, NY 13668 / 315-353-6100 (voice) / 315-353-6110 (fax) COPYRIGHT: This posting is part of "C++ FAQ Lite." The entire "C++ FAQ Lite" document is Copyright(C) 1991-96 Marshall P. Cline, Ph.D., cline@parashift.com. All rights reserved. Copying is permitted only under designated situations. For details, see section [1]. NO WARRANTY: THIS WORK IS PROVIDED ON AN "AS IS" BASIS. THE AUTHOR PROVIDES NO WARRANTY WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK, INCLUDING WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. C++-FAQ-Lite != C++-FAQ-Book: This document, C++ FAQ Lite, is not the same as the C++ FAQ Book. The book (C++ FAQs, Cline and Lomow, Addison-Wesley) is 500% larger than this document, and is available in bookstores. For details, see section [3]. ============================================================================== This "raw text" document was mechanically produced from the HTML version at: USA: http://www.cerfnet.com/~mpcline/c++-faq-lite/ U.K.: http://www.cs.bham.ac.uk/~jdm/CPP/index.html Germany: http://www.informatik.uni-konstanz.de/~kuehl/cpp/cppfaq.htm Finland: http://www.utu.fi/~sisasa/oasis/cppfaq/ Taiwan: http://www.cis.nctu.edu.tw/c++/C++FAQ-English/ If you have a Web browser, you probably want to read one of the above HTML sites instead of this document because: * The HTML version has many hyperlinked cross references. * The HTML version is MUCH easier to read than this "raw text" version. * The HTML version is updated more regularly than this "monthly posting". ============================================================================== Improve network response: * Use the closest mirror site (see URLs above). * Browse the FAQ off-line: Use the one-click download feature to get your own local copy.[NEW!] Look up stuff: * Look up a generic topic with the table of contents (35 coarse-grained topics). * Look up a specific topic with the extensive subject index (696 fine-grained topics). * Look up the changed topics with the chain of recent changes (28 changes for 11/96 and 1/97). Table of Contents: * [1] Copying permissions * [2] On-line sites that distribute this document * [3] C++-FAQ-Book versus C++-FAQ-Lite * [4] Recent changes to this document * [5] Netiquette when posting to comp.lang.c++ * [6] Big Picture issues * [7] Classes and objects * [8] References * [9] Inline functions * [10] Constructors * [11] Destructors * [12] Assignment operators * [13] Operator overloading * [14] Friends * [15] Input/output via and * [16] Freestore management * [17] Exceptions and error handling * [18] Const correctness * [19] Inheritance -- basics * [20] Inheritance -- virtual functions * [21] Inheritance -- proper inheritance and substitutability * [22] Inheritance -- abstract base classes (ABCs) * [23] Inheritance -- what your mother never told you * [24] Inheritance -- private and protected inheritance * [25] Coding standards * [26] Learning OO/C++ * [27] Learning C++ if you already know Smalltalk * [28] Reference and value semantics * [29] How to mix C and C++ * [30] Pointers to member functions * [31] Container classes and templates * [32] Class libraries * [33] Compiler dependencies * [34] Miscellaneous technical issues * [35] Miscellaneous environmental issues ============================================================================== Subject Index "A" * ABC (see also Inheritance) ... [22.2], [22.3] * Access rules - protected: and private: inheritance ... [24.6] - protected: and private: members ... [19.5], [19.6] * Acronyms ... [5.1] * Ada vs. C++ ... [6.4] * Aliasing - Aliasing of const and non-const pointers ... [18.9], [18.11], [18.12], [18.13] - References are aliases for objects ... [8.1], [8.5] * All Terrain Vehicle (ATV) ... [27.5] * ANSI ... [6.12] - ANSI-C ... [6.10] - ANSI-C++ committee "X3J16" ... [6.11], [27.1] * Arity ... [13.7] * Arrays - Arrays are evil ... [10.5], [13.6], [16.16], [17.3], [21.5] - Specifying length at runtime ... [16.17] * Assignment operator ... [12] - Check for self-assignment ... [22.5], [25.8] - Return *this ... [25.8] - Self-assignment ... [12.1], [12.2], [12.3] - Use const in parameter ... [25.8] * Associative array (see also STL) ... [31.1] * Associativity ... [13.7] * Author (see also C++ FAQ Lite) ... [1.1] * auto_ptr ... [17.2] "B" * Backtracking ... [5.3] * bad_alloc (see also Freestore) ... [16.5], [16.6] * Bag of Apple vs. of Fruit ... [21.3] * Base class ... [19.3] * Beautifier, Code (see Pretty printing) ... [35.2] * Big Picture issues (see Managerial issues) ... [6] * Big Three, Law of ... [16.16], [22.5], [25.8] * Binary compatibility between vendors ... [33.6] * Binding: Static vs. dynamic ... [20.2], [20.3] * Book (see C++ FAQ Book) ... [3] * Books on C++ ... [26] * BTW (Acronym) ... [5.1] * Business criteria dominate technical criteria ... [6.4] "C" * C++2LaTeX (see Pretty printing) ... [35.2] * C++ books ... [26] * C++ FAQ Book ... [3] - Available only in bookstores ... [3.3] - Is 500% bigger than this Lite document ... [3.4] - ISBN ... [3.1] - Not same as the on-line ("Lite") document ... [3.2] * C++ FAQ Lite ... [3] - Author ... [1.1] - Availability on-line ... [2] - Book is 500% bigger ... [3.4] - Chinese translation ... [2.4] - Copy permissions ... [1] - Copying permissions ... [1.3] - Copyright notice ... [1.2] - HTML version ... [2.2] - Mirror WWW sites ... [2.1] - No Warranty ... [1.4] - Not same as C++ FAQ Book ... [1.5], [3.2] - Plaintext version ... [2.3] - Recent changes ... [4] * C language - Accessing C++ data members from C ... [29.9] - C++ backward compatibility ... [6.10] - C++ is higher level than C ... [29.10] - C vs. C++ ... [6.4] - Calling C from C++ ... [29.5] - Calling C++ from C ... [29.6] - Coding standards different from C++ ... [25.3] - Common linker errors ... [23.4], [29.7] - __cplusplus ... [29.4] - extern C ... [29.3] - Including C headers ... [29.2], [29.3], [29.4] - Linking must be directed by C++ ... [29.1] - main() must be compiled using C++ ... [29.1] - Mixing C and C++ code ... [29] - Newsgroup comp.lang.c ... [5.8] - Not an efficient way to learn OO/C++ ... [26.2] - Passing C++ objects to C code ... [29.8], [29.9] - static at file-scope ... [7.5] * C++ Libraries FAQ ... [32.8] * Changes to this document (see also C++ FAQ Lite) ... [4] * char*: Use a string-like class instead ... [13.6], [17.3] * Chinese translation of this document ... [2.4] * Circles vs. Ellipses ... [21.6], [21.7], [21.8], [21.9] * class ... [7.1], [7.8] * clone() methods ... [16.21], [20.5], [22.5] * Coding standards ... [25] - Assignment operators check assignment-to-self ... [12.1], [25.8] - Assignment operators return *this ... [25.8] - Assignment operators use const ... [25.8] - Avoid arrays whenever possible ... [21.5] - Avoid dynamically typed libraries ... [32.4] - Avoid global variables ... [34.2] - Avoid hiding nested identifiers ... [34.2] - Bloodshed, Jihads, and Heat vs. Light ... [25.1] - Coding standards are never sufficient ... [25.2] - Coding standards are sometimes necessary ... [25.2] - Copy constructors use const ... [25.8] - Declare near first use ... [25.5] - Design classes from the outside-in ... [13.9] - Don't base C++ standards on C standards ... [25.3] - Don't test for NULL after new ... [16.5] - Don't test for NULL before delete ... [16.7] - Explicitly calling destructors (Don't!) ... [11.5], [11.6], [11.9] - Explicitly calling destructors (OK sometimes) ... [11.10] - Header filename extensions ... [25.7] - Identifier naming conventions ... [25.9] - Initialization lists ... [25.8] - Law of the Big Three ... [16.16], [25.8] - Operator overloading ... [25.8] - Source filename extensions ... [25.6] - static at file-scope (Don't!) ... [7.5] - The Ellemtel coding guidelines ... [25.10] - Todd Hoff's coding guidelines ... [25.10] - Use a string object rather than a char* ... [13.6], [17.3] - Use delete[] for arrays ... [16.11] - Use of the ternary ?: operator ... [25.4] - virtual destructor coding standard ... [25.8] * Combinations ... [5.3] * Committee Draft (CD) for ANSI/ISO-C++ ... [6.12] * Compatibility, Binary ... [33.6] * Compiler dependencies ... [33], [33.3] * Composition - Benefits compared to freestore ... [28.4], [28.5] - Compared with private inheritance ... [24.2] - Criteria for composition vs. private inheritance ... [24.3] - Inlining virtual functions ... [28.5], [28.6] * const_cast ... [18.10] * Const correctness ... [18], [18.1] - A form of type safety ... [18.2] - Aliasing of const and non-const pointers ... [18.12] - Coding standards concerning ... [25.8], [25.8] - const_cast ... [18.10], [18.11] - const member functions ... [18.9] - Fred& const x is nonsense ... [18.7] - Fred const& x -- use const Fred& x instead ... [18.8] - Immutable (const) pointers ... [18.5] - mutable ... [18.10] - Pointer-to-const ... [18.4], [18.5] - Pointer-to-const aliasing ... [18.13] - Reference-to-const ... [18.6] - Retrofitting const correctness is hard ... [18.3] * Constructors ... [10], [16.9] - Build objects from dust ... [10.1] - Calling a virtual from ... [23.1] - Calling another constructor ... [10.3] - Coding standards re. copy constructor ... [25.8] - Default constructors ... [10.4], [10.5] - Init methods ... [10.3] - Initialization coding standard ... [25.8] - Member objects should be self-managing ... [17.2] - Named Constructor Idiom ... [10.6], [16.18], [16.21] - Throwing exceptions ... [17.1] - Virtual Constructor Idiom ... [16.21], [20.5], [22.5] * Containers ... [31] - Container of Thing vs. of Anything ... [21.4] - Heterogeneous ... [31.2] - Iterators ... [31.3] * Copy constructors - Should use const ... [25.8] * Copy on write (see Reference counting) ... [16.20], [16.21] * Copy semantics (see also Value semantics) ... [28.1] * Copying permissions (see also C++ FAQ Lite) ... [1], [1.3] * Copyright notice (see also C++ FAQ Lite) ... [1.2] * Crash at runtime without any warning ... [11.5], [11.6], [16.2], [16.4], [16.11], [16.12], [17.3], [20.4], [21.1], [21.4], [21.5], [34.2] * create() methods (see Named Constructor Idiom) ... [10.6], [16.18], [16.21] * Ctor (see also Constructors) ... [10] "D" * Dangerous programming practices ... [11.5], [11.6], [11.10], [13.6], [16.2], [16.4], [16.11], [16.12], [16.16], [17.3], [20.4], [21.1], [21.4], [21.5], [23.3], [34.2] * Declarations - Declare near first use ... [25.5] - List x(); declares a function, not an object ... [10.2] * Decompiling executables back into C++ source code ... [33.2] * Default parameters ... [10.3] * #define macros (see also Inline functions) ... [9.1], [9.3], [26.2], [27.3], [29.4], [30.5], [30.6] * delete ... [16.1] - delete p actually deletes *p, not p ... [16.1] - delete this ... [16.14] - delete[] uses magic ... [16.13], [33.4], [33.5] - delete[] vs. delete ... [16.11] - delete[] vs. delete for builtin types ... [16.12] - Deleting an array with delete[] ... [16.10] - Mixing with malloc() ... [16.2] * Derived classes ... [19.3] - Can access protected parts of Base ... [19.7] - Can't access private parts of Base ... [19.6] - Derived* to Base* conversion ... [19.4], [21.2] - Derived** to Base** conversion (invalid) ... [21.2] - Derived* to private Base* conversion (invalid) ... [24.4] * Design books ... [26.7] * Destructors ... [11], [16.8], [16.13], [33.4], [33.5] - Base class subobjects are automagically destructed ... [11.12] - Calling a virtual from ... [23.1] - Can't be overloaded ... [11.4] - Coding standards concerning ... [25.8] - Controlling lifetimes of locals ... [11.6], [11.7], [11.8] - Explicitly calling them (Don't!) ... [11.5], [11.6], [11.9] - Explicitly calling them (OK sometimes) ... [11.10] - Last rites ... [11.1] - Member objects are automagically destructed ... [11.11] - Order of destruction for array elements ... [11.3] - Order of destruction for locals ... [11.2] - virtual destructor coding standard ... [20.4] * Dijkstra ... [5.3] * Directory separator: use "/", not "\" ... [15.10], [34.1] * Downloading - HTML version of C++ FAQ Lite ... [2.2] - HTML version of this document ... [2.1] - Plaintext version of C++ FAQ Lite ... [2.3] * Dtor (see also Destructors) ... [11] * Dynamic - Dynamic binding ... [6.7], [20.2], [20.3] - dynamic_cast ... [31.2] - Dynamic length arrays ... [16.17] - Dynamic typing ... [20.2], [27.2], [27.3], [32.4], [32.5] "E" * Ellemtel coding guidelines (see also Coding standards) ... [25.10] * Ellipses vs. Circles ... [21.6], [21.7], [21.8], [21.9] * Encapsulation ... [6.7], [7] - Definition ... [7.4] - Hides stuff from code, not from people ... [7.6] - Not necessarily violated by friends ... [14.2] - Security vs. Encapsulation ... [7.7] * End-of-file (see Input/output) ... [15.2], [15.4] * Equation parsing in C++ ... [5.3] * Etiquette (see also Netiquette) ... [5] * Exceptions ... [17] - Constructors can throw exceptions ... [17.1] - Example of throw; to re-throw current exception ... [16.9], [17.3], [33.4], [33.5] - Example of try ... catch ... [16.9], [17.3], [33.4], [33.5] - Member objects should be self-managing ... [17.2] * Executables -- decompiling back to C++ source code ... [33.2] * extern C (see also C language) ... [29], [29.3] "F" * Features of C++ from a business perspective ... [6.7] * Filenames - Extensions for header files ... [25.7] - Extensions for source code files ... [25.6] - Using "/" rather than "\" for directories ... [15.10], [34.1] * find_if ... [32.2] * Floating point ... [34.5], [35.5] * for loop ... [34.2] * FORTRAN vs. C++ ... [6.4] * free() (see also Freestore) ... [16.2] * Freestore ... [16] - Allocating an array with new T[n] ... [16.10] - Automating a NULL test ... [16.6] - bad_alloc ... [16.5], [16.6] - delete handles NULL automatically ... [16.7] - delete has two steps ... [16.8] - delete this ... [16.14] - delete[] uses magic ... [16.13], [33.4], [33.5] - delete[] vs. delete ... [16.11] - delete[] vs. delete for builtin types ... [16.12] - Deleting an array with delete[] ... [16.10] - Mixing malloc() and delete ... [16.2] - Mixing new and free() ... [16.2] - Multi-dimensional arrays ... [16.15], [16.16] - new has two steps ... [16.9] - new never returns NULL ... [16.5] - Placement new ... [11.10], [16.9] - Prohibiting local objects ... [16.18] - realloc() ... [16.4] - Reference counting ... [16.19], [16.20], [16.21] - Runtime costs of heap ... [28.4], [28.5] - set_new_handler ... [16.6] - Why use new rather than malloc() ... [16.3] * Friends ... [14] - Choosing between members and friends ... [14.5] - Definition of friend ... [14.1] - friend doesn't necessarily violate encapsulation ... [14.2] - Friendship privileges aren't inherited ... [14.4] - Friendship privileges aren't transitive ... [14.4] - istream operator>> ... [15.7] - ostream operator<< ... [15.6] - ostream operator<< (virtual) ... [15.8] - Pros and cons of friends ... [14.3] - Virtual Friend Function Idiom ... [14.3], [15.8] * From: line of a posting (see also Netiquette) ... [5.4] * FTP sites - 128.231.128.7 ... [32.5] - butler.hpl.hp.com ... [32.1] - ftp.cs.rpi.edu ... [32.1] - ftp.cygnus.com ... [6.12] - ftp.germany.eu.net ... [35.2] - ftp.maths.warwick.ac.uk ... [6.12], [6.12] - ftp.netlab.cs.rpi.edu ... [35.4] - ftpt.su.edu.au ... [6.12], [6.12] - garbo.uwasa.fi ... [5.8] - oak.oakland.edu ... [5.8] - research.att.com ... [6.12], [6.12] - rtfm.mit.edu ... [5.9] - venus.ycc.yale.edu ... [35.2] - www.cs.rpi.edu ... [32.1] - www.cygnus.com ... [35.2] - www.maths.warwick.ac.uk ... [32.1] * FWIW (Acronym) ... [5.1] * FYI (Acronym) ... [5.1] "G" * Generalization (see also Inheritance) ... [19.3] * Genericity (see also Templates) ... [31.8] * Global variables: Just Say No! ... [34.2] * GNU - emacs ... [35.3] - g++ ... [5.8] * Graphics ... [5.8] * Growth of C++ ... [6.5], [6.7] "H" * Has-a (see also Composition) ... [19.2], [24.2] * Header filename extensions ... [25.7] * Heap-sort ... [5.3] * Heat vs. light ... [25.1] * Heterogeneous containers ... [31.2] * Hiding inherited public features ... [21.1], [21.6], [21.7], [21.8] * Hiding rule ... [23.3] * Homework problems ... [5.2], [5.3] * Homogeneous containers ... [31.2] * Hostility ... [29.10] * How to learn OO/C++ ... [26] * HTML version of C++ FAQ Lite ... [2.2] * Hybrid OO programming languages ... [26.3] * Hype ... [6.3] "I" * Idioms - Named Constructor Idiom ... [10.6], [16.18], [16.21] - Virtual Constructor Idiom ... [16.21], [20.5], [22.5] - Virtual Friend Function Idiom ... [15.8] * IMHO (Acronym) ... [5.1] * Immutable (const) pointers ... [18.5] * IMNSHO (Acronym) ... [5.1] * IMO (Acronym) ... [5.1] * Imperfect programming languages ... [6.2] * #include - Including C headers ... [29.2], [29.3], [29.4] - Use forward slash "/", not backslash "\" ... [34.1] * indent (see Pretty printing) ... [35.2] * Indirection, Extra layers of ... [28.5] * Infix operators ... [5.3] * Inheritance ... [6.7], [19], [20], [21], [22], [23] - Abstract base classes (ABCs) ... [22], [22.2], [22.3] - Access of private: by derived ... [19.6] - Access of protected: and private: ... [19.5] - Access of protected: by derived ... [19.7] - Array of Derived vs. of Base ... [21.4] - Calling virtuals from constructors ... [23.1] - Circle vs. Ellipse ... [21.6], [21.7], [21.8], [21.9] - Derived* to Base* conversion ... [19.4], [21.2] - Derived** to Base** conversion (invalid) ... [21.2] - Derived* to private Base* conversion (invalid) ... [24.4] - Differences between C++ and Smalltalk inheritance ... [27.4] - Hiding inherited public features ... [21.1] - Hiding rule ... [23.3] - How to code inheritance ... [19.3] - Importance of inheritance ... [19.1] - Is-a-kind-of ... [19.2] - Multiple inheritance ... [6.7], [11.12], [24.2], [29.8], [29.9], [33.6], [33.9] - Old code calls new code ... [6.9] - Parking-lot of Car vs. of Vehicle ... [21.3] - private inheritance ... [24], [24.1] - private inheritance access rules ... [24.6] - private inheritance vs. composition ... [24.2], [24.3] - protected inheritance access rules ... [24.6] - protected vs. private inheritance ... [24.5] - Pure virtual functions ... [22.4] - Redefining non-virtuals ... [23.2] - Smalltalk differences ... [27.5] - Specification device ... [19.2] - virtual constructors ... [16.21], [20.5], [22.5] - virtual data ... [28.2], [28.3] - virtual destructor coding standard ... [20.4] - virtual functions ... [20.1] - virtual functions are central to OO ... [6.8] - virtual inheritance ... [11.12], [29.8], [29.9], [33.6], [33.9] - What your Mother didn't tell you ... [23] - When to use inheritance ... [19.2] * Initialization lists (see also Coding standards) ... [25.8] * Initialization of a static member datum ... [10.7], [10.8] * Inline functions ... [9] - Better than #define macros ... [9.3] - Can degrade performance ... [9.7] - Defined outside class body ... [9.5] - Defined within class body ... [9.6] - Inlining virtual functions ... [28.5], [28.6] - Like a #define macro ... [9.1] - Member functions ... [9.5] - Non-member functions ... [9.4] - Safety without loss of speed ... [6.7], [9.2] * Input/output ... [15] - Binary mode on MS-DOS ... [15.9] - istream and eof ... [15.2], [15.4] - istream and invalid input characters ... [15.2] - istream and while (cin >> foo) ... [15.3] - istream operator>> ... [15.7] - istream remembers bad state ... [15.5] - ostream operator<< ... [15.6] - ostream operator<< (virtual) ... [15.8] * Inspector methods ... [18.9] * Interfaces - A simplified view in the user's vocabulary ... [7.3] - Abstract base classes (ABCs) ... [22.2] - Design interfaces from the outside-in ... [13.9] - Goal of interface design ... [7.4] - More valuable than implementation ... [22.1] - protected interface ... [19.7] - Separate from implementation ... [22.2] * Intuition isn't always correct ... [21.3], [21.4], [21.6], [21.7], [21.8] * Invalid input characters (see Input/output) ... [15.2] * iostream.h ... [15.1] * Is-a-kind-of (see also Inheritance) ... [19.2] * ISO ... [6.12] - ISO-C ... [6.10] - ISO-C++ committee "WG21" ... [6.11] * Iterators ... [31.3] "J" * Java vs. C++ ... [6.4] "K" * Kind-of (see also Inheritance) ... [19.2] * Kruskal ... [5.3] * KUTGW (Acronym) ... [5.1] "L" * Language wars ... [6.4] * Large executables ... [32.7], [33.7] * Last rites (see also Destructors) ... [11.1] * LaTeX - C++2LaTeX pretty printer ... [35.2] - Macros for "C++" ... [35.1] * Law of the Big Three ... [16.16], [22.5], [25.8] * Layer of indirection ... [28.5] * Learning OO/C++ ... [26] * Learning OO/C++ - How long does it take ... [6.6] - No need to learn C first ... [26.2] - No need to learn Smalltalk first ... [26.3] * Legality books on C++ ... [26.4], [26.6] * Length of time needed to learn OO/C++ ... [6.6] * Libraries FAQ ... [32.8] * Libraries ... [32] - Dynamically typed C++ libraries ... [32.4], [32.5] - Large executables ... [32.7], [33.7] - Numerical Recepies ... [32.6] - STL ... [32.1], [32.3] * Lifetime of objects - Controlling lifetime of locals ... [11.6], [11.7], [11.8] - In heterogeneous containers ... [31.2] - New rule for for loop variables ... [34.2] - Order of destruction for array elements ... [11.3] - Order of destruction for locals ... [11.2] - Register liveness ... [28.5] - Using friend classes to achieve separate lifetimes ... [14.2] * Linker errors ... [10.8], [23.4], [29.7], [35.5] "M" * malloc() - (See also Freestore) ... [16.2] - Why new is preferred over malloc() ... [16.3] * Managerial issues ... [6] - Business-centricity vs. Techno-centricity ... [6.4] - C++ is a practical tool ... [6.1] - C++ is not a perfect tool ... [6.2] - Growth of C++ ... [6.5] - Length of time needed to learn OO/C++ ... [6.6] - Some advantages of OO ... [6.3] - Standardization of C++ ... [6.11], [6.12] * map (see also STL) ... [31.1] * Maseratti ... [27.5] * Matrix subscript operator ... [13.8] * Mentoring ... [6.6], [26.1] * Merge-sort ... [5.3] * MFC ... [33.1] * Microsoft Windows ... [5.8], [15.9], [35.4] * Minimum Spanning Trees in C++ ... [5.3] * Mirror sites (see also This document) ... [2] * Mixing - Mixing C and C++ code (see also C language) ... [29] - Mixing malloc() and delete ... [16.2] - Mixing new and free() ... [16.2] * Monolithic class hierarchies ... [32.4], [32.5] * Morality books on C++ ... [26.4], [26.5] * MS-DOS ... [5.8], [15.9], [35.4] * Multi-dimensional arrays ... [16.15], [16.16] * Multiple - Multiple encapsulated instances ... [6.7], [7.5], [31.3] - Multiple inheritance ... [6.7], [11.12], [24.2], [29.8], [29.9], [33.6], [33.9] * mutable ... [18.10] * Mutator methods ... [18.9] * MYOB (Acronym) ... [5.1] "N" * Named Constructor Idiom ... [10.6], [16.18], [16.21] * Netiquette ... [5] - From: line of a posting ... [5.4] - General netiquette ... [5.4] - Getting and reading other FAQs ... [5.9] - Posting code ... [5.7] - Reply-to: line of a posting ... [5.4] - Selecting an appropriate newsgroup ... [5.8] - Subject: line of a posting ... [5.6] * new - Advantages over malloc() ... [16.3] - Allocating an array with new T[n] ... [16.10] - Mixing with free() ... [16.2] - (See also Freestore) ... [16.1] * New handler (see also Freestore) ... [16.6] * Newsgroups - comp.graphics ... [5.8] - comp.lang.c ... [5.8] - comp.lang.c++ ... [5.8] - comp.lang.c++.moderated ... [5.8] - comp.object ... [5.8] - comp.os.ms-windows.programmer.misc ... [5.8] - comp.os.ms-windows.programmer.tools ... [5.8] - comp.os.msdos.programmer ... [5.8], [35.4] - comp.os.msdos.programmer.turbovision ... [5.8] - comp.programming ... [5.8] - comp.sources.wanted ... [5.8] - comp.std.c++ ... [5.8] - comp.sys.mac.oop.* ... [5.8] - comp.sys.mac.programmer.* ... [5.8] - comp.unix.programmer ... [5.8], [35.4] - comp.unix.solaris ... [5.8] - comp.windows.ms.programmer ... [35.4] - gnu.g++.bug ... [5.8] - gnu.g++.help ... [5.8] * NIHCL (National Institute of Heath Class Library) ... [32.5] * No Warranty (see also C++ FAQ Lite) ... [1.4] * Nuclear submarine ... [21.2] * NULL ... [16.5], [16.6] * Numerical Recepies code ... [32.6] "O" * Object ... [7.2] * Object-oriented: So what? ... [6.3] * Old code calls new code ... [6.9] * OO design books ... [26.7] * ?: operator ... [25.4] * Operator ?: ... [25.4] * Operator overloading ... [6.7], [13] - Assignment operator ... [12], [22.5] - Can't invent new operators ... [13.7] - Can't replace behavior on builtins ... [13.6] - Coding standards ... [25.8] - Does help the users of a class ... [13.2] - Does not help the developer of a class ... [13.4] - Examples ... [13.3] - operator!= ... [13.9] - operator() ... [13.8] - operator++ ... [13.9] - operator[] ... [13.8] - operator delete(void*) ... [16.8], [16.11] - operator delete[](void*) ... [16.11] - operator* (dereference operator) ... [13.9] - operator>> (istream input) ... [15.7] - operator new(size_t) ... [16.9] - operator<< (ostream output) ... [15.6] - operator<< (ostream output; virtual) ... [15.8] - Purpose of operator overloading ... [13.1] - Self-assignment ... [12.1], [12.2], [12.3] - Which operators can be overloaded ... [13.5] * Optimization - const_cast ... [18.11] * OS/2 ... [15.9] * OTOH (Acronym) ... [5.1] * Overloading - Can't overload by return type ... [34.3] - Operators (see Operator overloading) ... [6.7] "P" * Paradigm shifts ... [6.6], [29.10] * Parameterized types (see also Templates) ... [31.7] * Parking lots ... [21.3] * Part-of (see also Composition) ... [19.2], [24.2] * Pascal vs. C++ ... [6.4] * Passing parameters - By pointer ... [8.1] - By reference ... [8.1], [28.8] - By value ... [28.8] * Perfect programming languages ... [6.2] * Permissions to copy this document ... [1] * Permutations ... [5.3] * Persistence ... [32.4], [32.5], [34.4] * Placement new ... [16.9] * Plaintext version of C++ FAQ Lite ... [2.3] * Pointer semantics (see also Reference semantics) ... [28.1] * Pointer-to-const ... [18.4], [18.5], [18.13] * Pointer to function (see Pointer to member) ... [30.1] * Pointer to member ... [30] - Address of a C++ method ... [30.4] - Array of pointer-to-member ... [30.6] - Contrast to pointer-to-function ... [30.1] - Converting to pointer-to-function ... [30.2], [30.3] - Passing as pointer-to-function ... [30.2] * Polymorphism ... [6.7] * Postfix operators ... [5.3] * Posting code (see also Netiquette) ... [5.7] * Pragmatics ... [6.1] * Precidence ... [13.7] * Prepare to die! (see also Destructors) ... [11.1] * Pretty printing - C++2LaTeX ... [35.2] - C-Clearly ... [35.2] - GNU indent ... [35.2] - tgrind ... [35.2] * Prim ... [5.3] * private inheritance ... [24], [24.1] - Access rules ... [24.6] - Compared with composition ... [24.2] - Criteria for private inheritance vs. composition ... [24.3] - Derived* to private Base* conversion (invalid) ... [24.4] - private vs. protected inheritance ... [24.5] * private: members ... [19.5], [19.6] * Proficiency in OO/C++: How long does it take ... [6.6] * protected inheritance - Access rules ... [24.6] - protected vs. private inheritance ... [24.5] * protected: members ... [19.5] - The protected: interface ... [19.7] * public: inheritance ... [19], [20], [21], [22], [23] * public: members ... [19.5] - The public: interface ... [19.7] * Pure OO programming languages ... [26.3] * Pure virtual functions ... [22.3], [22.4] "Q" * Quick-sort ... [5.3] "R" * realloc() (see also Freestore) ... [16.4] * Recent changes to this document (see also C++ FAQ Lite) ... [4] * Redefining non-virtuals ... [23.2] * Reference counting - Copy on write ... [16.20], [16.21] - Pointer semantics ... [16.19] - Reference semantics ... [16.20] - Reference semantics for a hierarchy ... [16.21] * Reference semantics ... [28], [28.7], [28.8] * References ... [8] - Assigning a reference ... [8.2] - References to const ... [18.1], [18.6] - References vs. pointers ... [8.5] - Reseating a reference ... [8.4], [18.7], [18.8] - Returning a reference ... [8.3] * Reply-to: line of a posting (see also Netiquette) ... [5.4] * Return type ... [34.3] * RTFM (Acronym) ... [5.1] * rtfm.mit.edu ... [5.9] * Runtime crashes without any warning ... [11.5], [11.6], [16.2], [16.4], [16.11], [16.12], [17.3], [20.4], [21.1], [21.4], [21.5], [34.2] "S" * Security vs. Encapsulation (see also Encapsulation) ... [7.7] * Self-assignment ... [12.1], [12.2], [12.3], [25.8] * Self-cleaning member objects ... [17.2] * set_new_handler (see also Freestore) ... [16.6] * Short-courses (one 40 hour workweek) ... [6.6] * Shortest path in C++ ... [5.3] * Smalltalk ... [27] - Differences with C++ ... [27.1] - Dynamic type checking ... [27.2] - Inheritance differences ... [27.4], [27.5] - Language wars vs. C++ ... [6.4] - Not an efficient way to learn OO/C++ ... [26.3] * Smart pointers ... [13.3], [16.19], [17.2] * SO (Acronym) ... [5.1] * Solaris ... [5.8] * Sorting in C++ ... [5.3] * Source filename extensions ... [25.6] * Spanning Trees in C++ ... [5.3] * Specialization (see also Inheritance) ... [19.3] * Standardization issues ... [5.8], [6.11], [6.12], [27.1] * Static - Common linker errors due to static data members ... [10.8] - Define static data members explicitly ... [10.7], [10.8] - Named Constructor Idiom using static ... [10.6], [16.18], [16.21] - static at file-scope (Don't!) ... [7.5] - Static binding ... [20.2], [20.3] - static create() methods ... [10.6], [16.18], [16.21] - Static typing ... [20.2], [27.2], [27.3] * Status bar with MFC ... [33.1] * stdio.h ... [15.1] * STL ... [32.2] - Access to on-line help ... [32.3] - FTP sites ... [32.1] - map ... [31.1] - vector ... [10.5], [16.17], [21.4], [21.5], [32.2] * string: Better than char* ... [13.6], [17.3] * struct ... [7.1], [7.8] * Style guidelines (see Coding standards) ... [25] * Subclass - See also Inheritance ... [19.3] - Subclasses that aren't subtypes ... [27.5] * Subject: line of a posting (see also Netiquette) ... [5.6] * Submarines, Nuclear ... [21.2] * Subscript operator for Matrix ... [13.8] * Substitutability ... [21.3], [21.4], [21.6], [21.7], [21.8] * Subtypes that aren't subclasses ... [27.5] * Superclass (see also Inheritance) ... [19.3] * Syntactic sugar ... [13.1] "T" * .tar.gz (see Downloading) ... [2.2], [2.3] * .tar.Z (see Downloading) ... [2.2], [2.3] * Templates ... [31] - Basics of templates ... [31.4] - Class template is a family of classes ... [31.6] - Function template is a family of functions ... [31.5] - Genericity ... [31.8] - Parameterized types ... [31.7] * Ternary operator: ?: ... [25.4] * TeX macros for "C++" ... [35.1] * tgrind (see Pretty printing) ... [35.2] * This document (see also C++ FAQ Lite) ... [3] * throw ... [16.5], [16.6] * To-the-power-of operator** (Can't!) ... [13.7] * Todd Hoff's coding guidelines (see also Coding standards) ... [25.10] * Training ... [6.6] * Transitivity ... [14.4] * Type safety - Comparison with Smalltalk ... [27.2] - Const correctness ... [18.2] - Static vs. dynamic typing ... [20.2] * typeid() ... [31.2] "U" * Uncompiling executables back into C++ source code ... [33.2] * Unix ... [5.8], [35.4] * Unresolved external (see also Linker errors) ... [23.4] * Usenet newsgroups (see also Newsgroups) ... [5.8] "V" * v-pointer (see also virtual) ... [20.3], [33.6] * v-table (see also virtual) ... [20.3], [21.4], [23.4], [33.6] * Value semantics ... [28], [28.7], [28.8] * vector (see also STL) ... [10.5], [16.17], [21.4], [21.5], [32.2] * Version numbers to the "language" ... [33.9] * virtual - Binary compatibility of virtual functions ... [33.6] - Calling virtual functions from constructors ... [23.1] - Calling virtual functions from destructors ... [23.1] - Inlining virtual functions ... [28.5], [28.6] - Pure virtual functions ... [22.3], [22.4] - Redefining non-virtual member functions ... [23.2] - v-pointer (virtual pointer) ... [20.3], [33.6] - v-table (virtual table) ... [20.3], [21.4], [23.4], [33.6] - Virtual Constructor Idiom ... [16.21], [20.5], [22.5] - virtual data ... [28.2], [28.3] - virtual destructor coding standard ... [20.4], [25.8] - Virtual Friend Function Idiom ... [14.3], [15.8] - virtual functions ... [20] - virtual functions are central to OO ... [6.8] - virtual functions let old code call new code ... [6.9] - virtual functions, purpose of ... [20.1] - virtual inheritance ... [11.12], [29.8], [29.9], [33.6], [33.9] * Visual Basic vs. C++ ... [6.4] "W" * Wars ... [25.1] * WWW sites of this document ... [2.1] "X" * X3 Secretariat ... [6.12] "Y" * Yaccable grammar ... [33.8] "Z" * .zip (see Downloading) ... [2.2], [2.3] * Zombie objects ... [17.1] ============================================================================== SECTION [1]: Copying permissions [1.1] Author Marshall Cline, cline@parashift.com Paradigm Shift, Inc. One Park St. Norwood, NY 13668 315-353-6100 (voice) 315-353-6110 (fax) ============================================================================== [1.2] Copyright Notice The entire C++ FAQ Lite document is Copyright (C) 1991-96 Marshall P. Cline, Ph.D., cline@parashift.com. All rights reserved. Copying is permitted only under designated situations[1.3]. ============================================================================== [1.3] Copying Permissions [UPDATED!] [Recently simplified (on 1/97).] If all you want to do is quote a small portion of C++ FAQ Lite (such as one or two FAQs) in a larger document, simply attribute the quoted portion with something vaguely similar to, "From Marshall Cline's C++ FAQ Lite document, http://www.cerfnet.com/~mpcline/c++-faqs-lite/". If you want to make a copy of large portions and/or the entire C++ FAQ Lite document for your own personal use, you may do so without restriction (provided, of course, that you don't redistribute the document to others, or allow others to copy the document). If you want to redistribute large portions and/or the entire C++ FAQ Lite document to others, whether or not for commercial use, you must get permission from the author first (and that permission is normally granted; note however that it's often easier for you to simply tell your recepients about the one-click download option[2.2]). In any event, you must retain and consipicuously display all copyright notices on all copies of the documents you copy, and you must include and conspicuously display the Author[1.1], Copyright Notice[1.2], No Warranty[1.4], C++-FAQ-Lite != C++-FAQ-Book[1.5], and Copying Permissions[1.3] items, and display these items conspicuously. If you want more and/or different privileges than are outlined here, please contact me, cline@parashift.com. I'm a very reasonable man... ============================================================================== [1.4] No Warranty THIS WORK IS PROVIDED ON AN "AS IS" BASIS. THE AUTHOR PROVIDES NO WARRANTY WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK, INCLUDING WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. ============================================================================== [1.5] C++-FAQ-Lite != C++-FAQ-Book This document, C++ FAQ Lite, is not the same as the C++ FAQ Book. The book (C++ FAQ, Cline and Lomow, Addison-Wesley) is 500% larger than this document, and is available in bookstores. See [3] for details. ============================================================================== SECTION [2]: On-line sites that distribute this document [2.1] Where's the closest mirror site to access this document? [UPDATED!] [Recently removed the "USA-2" site (on 1/97).] You'll get better response time by choosing a close site: * USA: http://www.cerfnet.com/~mpcline/c++-faq-lite/ * U.K.: http://www.cs.bham.ac.uk/~jdm/CPP/index.html * Germany: http://www.informatik.uni-konstanz.de/~kuehl/cpp/cppfaq.htm * Finland: http://www.utu.fi/~sisasa/oasis/cppfaq/ * Taiwan: http://www.cis.nctu.edu.tw/c++/C++FAQ-English/ ============================================================================== [2.2] How can I get a Copy of all the HTML files of C++ FAQ Lite so I can read them Off-Line? [NEW!] [Recently created (on 11/96) and rewrote and added a one-click feature to get .zip, .tar.Z or .tar.gz format (on 1/97).] Here's how you can get a bundled and compressed copy of the HTML files of C++ FAQ Lite: 1. Decide between .zip, .tar.Z, or .tar.gz formats and send an (empty) e-mail message to the associated address (.zip is common on Windows and the Mac; .tar.Z and .tar.gz are common on UNIX): for a .zip file, use cline-c++-faq-html-zip@crynwr.com; for a .tar.Z file, use cline-c++-faq-html-tarz@crynwr.com; for a .tar.gz file, use cline-c++-faq-html-targz@crynwr.com. 2. Wait a few minutes, then check your e-mail. If you don't receive an e-mail message containing the bundled FAQ, wait a while longer and check again. If you still haven't received it after waiting an entire day, something is wrong and you can send me e-mail or try again. 3. Once you receive the FAQ in your e-mail, unpack the FAQ using the instructions contained in the associated e-mail message. Note: e-mail was selected as the preferred delivery mechanism because it's the best choice for people overseas (so they don't have to wait while the packets cross the ocean). So please please don't send me e-mail asking for an FTP address since there isn't one. Thanks! Restriction: you must still abide by the Copyright Notice[1.2] and Copying Permissions[1.3]. In particular, you must not redistribute C++ FAQ Lite to others without permission from the author[1.1]. If you want to redistribute C++ FAQ Lite to someone else, the easiest way is to tell them about this one-click download feature[2.2], and let them get their own copy. Restriction: the FAQ uses "long filenames." If your machine can't handle long filenames (e.g., if it's DOS and/or Windows 3.x), you cannot unpack the FAQ. UNIX, Windows NT, Windows 95, and Mac all handle long filenames correctly. ============================================================================== [2.3] How can I get a Copy of all the "plaintext" files of C++ FAQ Lite so I can read them Off-Line? [UPDATED!] [Recently rewrote and added a one-click feature to get .zip, .tar.Z or .tar.gz format (on 1/97).] The "plaintext" version of C++ FAQ Lite is posted monthly on comp.lang.c++. These simple text files are mechanically produced by stripping the HTML tags from the HTML files on the Web site. Therefore the plaintext files aren't as pretty to look at and don't have the hyper-linked corss references, but they have basically the same information as the HTML files. Here's how you can get a bundled and compressed copy of the plaintext files of C++ FAQ Lite: 1. Decide between .zip, .tar.Z, or .tar.gz formats and send an (empty) e-mail message to the associated address (.zip is common on Windows and the Mac; .tar.Z and .tar.gz are common on UNIX): for a .zip file, use cline-c++-faq-plaintext-zip@crynwr.com; for a .tar.Z file, use cline-c++-faq-plaintext-tarz@crynwr.com; for a .tar.gz file, use cline-c++-faq-plaintext-targz@crynwr.com. 2. Wait a few minutes, then check your e-mail. If you don't receive an e-mail message containing the bundled FAQ, wait a while longer and check again. If you still haven't received it after waiting an entire day, something is wrong and you can send me e-mail or try again. 3. Once you receive the FAQ in your e-mail, unpack the FAQ using the instructions contained in the associated e-mail message. Note: e-mail was selected as the preferred delivery mechanism because it's the best choice for people overseas (so they don't have to wait while the packets cross the ocean). So please please don't send me e-mail asking for an FTP address since there isn't one (e.g., rtfm.mit.edu always seems hopelessly out-of-date). Thanks! Restriction: you must still abide by the Copyright Notice[1.2] and Copying Permissions[1.3]. In particular, you must not redistribute C++ FAQ Lite to others without permission from the author[1.1]. If you want to redistribute C++ FAQ Lite to someone else, the easiest way is to tell them about this one-click download feature[2.2], and let them get their own copy. ============================================================================== [2.4] Where can I download a Chinese translation of this on-line document? http://www.cis.nctu.edu.tw/c++/C++FAQ-Chinese/ contains a Chinese translation encoded in the "Big5" code. Note: "Big5" is a 16-bit Chinese code used mostly in Taiwan. ============================================================================== SECTION [3]: C++-FAQ-Book versus C++-FAQ-Lite [3.1] Is there a C++ FAQ Book I can buy in a bookstore? Yes. C++ FAQ by Cline and Lomow, Addison-Wesley, 1995, ISBN 0-201-58958-3. ============================================================================== [3.2] Is this on-line ("Lite") document the same as the C++ FAQ Book? No! Many people have asked about the relationship between the book and this Lite document. In particular, many have wondered whether this Lite document and the book are equivalent. They are not. The book (C++ FAQ, Addison-Wesley, 1995) contains roughly 500% more information than this Lite document. For example, the book covers both a wider variety of topics and provides deeper details and insights than this Lite document. The book also includes thousands of cross references, external references, and index terms, as well as many more programming examples. ============================================================================== [3.3] How can I download a free copy of the C++ FAQ Book? URL: sneaker-net://your.local.bookstore/tech-section/ISBN=0-201-58958-3 In other words, the book is available in bookstores (C++ FAQs, Addison-Wesley, 1995; ISBN 0-201-58958-3). It is not available in any on-line forum. Note that you can get a peek at some excerpts from the book via http://www.aw.com/cseng/authors/cline/FAQ/FAQ.html ============================================================================== [3.4] Why would I spend good money on a book when I can download it for free? Because you can't download the contents of the book for free. The book and this Lite document are not the same. The book contains 500% more material than this Lite document. ============================================================================== -- Marshall Cline, Ph.D., President, Paradigm Shift, Inc. 315-353-6100 (voice) 315-353-6110 (fax) mailto:cline@parashift.com