home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-03-01 | 46.7 KB | 1,045 lines |
- Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!newsfeed.skycache.com!news.maxwell.syr.edu!newsfeed.novia.net.MISMATCH!novia!nntp3.cerf.net!nntp2.cerf.net!news.cerf.net!not-for-mail
- From: mpcline@nic.cerf.net (Marshall Cline)
- Newsgroups: comp.lang.c++,comp.answers,news.answers,alt.comp.lang.learn.c-c++
- Subject: C++ FAQ (part 2 of 10)
- Followup-To: comp.lang.c++
- Date: 29 Feb 2000 20:06:27 GMT
- Organization: ATT Cerfnet
- Lines: 1024
- Approved: news-answers-request@mit.edu
- Distribution: world
- Expires: +1 month
- Message-ID: <89h8s3$btp$1@news.cerf.net>
- Reply-To: cline@parashift.com (Marshall Cline)
- NNTP-Posting-Host: nic1.san.cerf.net
- X-Trace: news.cerf.net 951854787 12217 192.215.81.88 (29 Feb 2000 20:06:27 GMT)
- X-Complaints-To: abuse@cerf.net
- NNTP-Posting-Date: 29 Feb 2000 20:06:27 GMT
- Summary: Please read this before posting to comp.lang.c++
- Xref: senator-bedfellow.mit.edu comp.lang.c++:453817 comp.answers:39857 news.answers:178216 alt.comp.lang.learn.c-c++:40795
-
- Archive-name: C++-faq/part2
- Posting-Frequency: monthly
- Last-modified: Feb 29, 2000
- URL: http://marshall-cline.home.att.net/cpp-faq-lite/
-
- AUTHOR: Marshall Cline / cline@parashift.com / 972-931-9470
-
- COPYRIGHT: This posting is part of "C++ FAQ Lite." The entire "C++ FAQ Lite"
- document is Copyright(C)1991-2000 Marshall 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].
-
- ==============================================================================
-
- SECTION [4]: Recent changes to this document
-
-
- [4.1] What updates were made for the 03/00 release? [NEW!]
-
- [Recently created (on 3/00).]
-
- New FAQs:
- * [4.1] What updates were made for the 03/00 release?
- * [34.1] What should be done with macros that contain if?
- * [34.2] What should be done with macros that have multiple lines?
- * [34.3] What should be done with macros that need to paste two tokens
- together?
-
- Changed FAQs:
- * [2.6] Where can I download a Portuguese translation of this on-line
- document?
- (updated the URL for the Portuguese translation of the FAQ thanks to Ricardo
- F. de Oliveira)
- * [3.1] Is there a C++ FAQ Book in addition to the C++ FAQ Lite?
- (rewrote)
- * [3.2] Is there a big difference between C++ FAQ Lite and C++ FAQ Book?
- (rewrote)
- * [3.3] How can I download an electronic copy of the C++ FAQ Book?
- (rewrote)
- * [6.12] Where can I get a copy of the ANSI/ISO C++ standard?
- (changed the URL for the electronic copy of the Standard thanks to Wolfgang
- Haefelinger)
- * [9.3] Why should I use inline functions? Why not just use plain old #define
- macros?
- (added cross references to other evilness of macros)
- * [11.8] What if I can't wrap the local in an artificial block?
- (added the note about constructors at the end)
- * [13.10] Should I design my classes from the outside (interfaces first) or
- from the inside (data first)?
- (added friend relationship between LinkedListIterator and LinkedList thanks
- to M≤nica Garcφa Garcφa; reworded "In the case of OO software..." sentence
- thanks to Fabrice Clerc)
- * [18.10] What do I do if I want to update an "invisible" data member inside a
- const member function?
- (added a warning against use of const_cast on const objects thanks to TiTi)
- * [20.5] What is a "virtual constructor"?
- (added the paragraph on Covariant Return Types)
- * [27.3] Which is a better fit for C++: "static typing" or "dynamic typing"?
- (added cross references to evilness of macros)
- * [29.4] How can I modify my own C header files so it's easier to #include
- them in C++ code?
- (added the "macros are sometimes useful" paragraph at the end)
- * [30.1] Is the type of "pointer-to-member-function" different from
- "pointer-to-function"?
- (changed another "It's" to "Its" thanks to Chris Young)
- * [30.5] How can I avoid syntax errors when calling a member function using a
- pointer-to-member-function?
- (added the "macros are sometimes useful" paragraph at the end)
- * [30.6] How do I create and use an array of pointers to member functions?
- (added the "macros are sometimes useful" paragraph at the end)
-
- ==============================================================================
-
- [4.2] What updates were made for the 01/00 release? [NEW!]
-
- [Recently created (on 1/00).]
-
- New FAQs:
- * [4.2] What updates were made for the 01/00 release?
- * [10.7] Should you use the this pointer in the constructor?
- (with the help of Jim Hyslop)
- * [25.4] What's the difference between <xxx> and <xxx.h> headers?
- (thanks to Stan Brown)
-
- Changed FAQs:
- * [2.1] Where's the closest mirror site to access this document?
- (changed the rationale for choosing a close site thanks to Stan Brown)
- * [2.4] Why is the download via email? Why not via ftp?
- (added caveat that out-of-date reminders aren't implemented yet thanks to
- Stan Brown)
- * [5.1] What does IMHO mean? (or IMO, IMNSHO, FWIW, OTOH, etc.)?
- (added IMAO thanks to Charles R Martin)
- * [5.9] How do I get the FAQs for a particular newsgroup?
- (added www.faqs.org thanks to Dan Kegel)
- * [6.8] Are virtual functions (dynamic binding) central to OO/C++?
- (reworded the second paragraph thanks to Stan Brown)
- * [6.11] Is C++ standardized?
- (changed "American National Standards Organization" to "American National
- Standards Institute" thanks to Mark Jones; also reworded first paragraph thanks
- to Stan Brown)
- * [12.1] What is "self assignment"?
- (changed "knowning" to "knowing" thanks to Stan Brown)
- * [12.3] OK, OK, already; I'll handle self-assignment. How do I do it?
- (reworded the last paragraph thanks to Stan Brown)
- * [13.5] What operators can/cannot be overloaded?
- (got rid of #if/#else/#endif by splitting the example thanks to Stan Brown)
- * [15.10] Why can't I open a file in a different directory such as
- "..\test.dat"?
- (added an explanation that the library routines treat "/" and "\"
- interchangeably thanks to Stan Brown)
- * [18.13] Does "const Fred* p" mean that *p can't change?
- (added an indication that there might be other non-const ways to get at the
- object thanks to Stan Brown)
- * [20.2] How can C++ achieve dynamic binding yet also static typing?
- (added the definition of polymorphism thanks to Kemberli Jennings)
- * [22.5] How do you define a copy constructor or assignment operator for a
- class that contains a pointer to a (abstract) base class?
- (fixed Circle and Square so they inherit from Shape thanks to Paul Campbell)
- * [30.1] Is the type of "pointer-to-member-function" different from
- "pointer-to-function"?
- (changed "It's type is..." to "Its type is..." thanks to Graham Borland)
- * [31.3] How can I insert/access/change elements from a linked
- list/hashtable/etc?
- (reworded first 4 paragraphs thanks to Stan Brown)
- * [33.2] Where can I get more information on using MFC and Visual C++?
- (updated the URL thanks to Katy Mulvey; changed the maintainer's name thanks
- to AllanW)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (changed the URL for Watcom C++ thanks to Stephen Howe; added Comeau C++
- thanks to Gary Comeau)
-
- ==============================================================================
-
- [4.3] What updates were made for the 10/99 release?
-
- New FAQs:
- * [2.7] Where can I download a French translation of this on-line document?
- * [4.3] What updates were made for the 10/99 release?
- * [13.9] Why shouldn't my Matrix class's interface look like an
- array-of-array?
- * [32.1] What is the "STL"?
- * [34.9] How can I create two classes that both know about each other?
- (thanks to Steve Horne)
- * [34.10] What special considerations are needed when forward declarations are
- used with member objects?
- (thanks to Steve Horne)
- * [34.11] What special considerations are needed when forward declarations are
- used with inline functions?
- (thanks to Steve Horne)
- * [34.12] Why can't I put a forward-declared class in a vector<>?
- (thanks to Steve Horne)
-
- Changed FAQs:
- * [6.11] Is C++ standardized?
- (changed "International Standards Organization" to "International
- Organization for Standardization" thanks to savvysoft2@aol.com)
- * [7.1] What is a class?
- (cleaned up wording so no one thinks int is a class thanks to Ron Natalie)
- * [8.1] What is a reference?
- (added return type to main())
- * [8.2] What happens if you assign to a reference?
- (inserted "state of the" to avoid ambiguity thanks to Donna)
- * [8.3] What happens if you return a reference?
- (added return type to main())
- * [10.5] Which constructor gets called when I create an array of Fred objects?
- (added return type to main(), plus added stuff about "explicit
- initialization of arrays" thanks to Keller Beyer)
- * [10.8] What is the "Named Constructor Idiom"?
- (added return type to main())
- * [12.1] What is "self assignment"?
- (added return type to main())
- * [13.4] But operator overloading makes my class look ugly; isn't it supposed
- to make my code clearer?
- (added return type to main())
- * [13.5] What operators can/cannot be overloaded?
- (added return type to main())
- * [13.6] Can I overload operator== so it lets me compare two char[] using a
- string comparison?
- (replaced "class type" with "user-defined type" in first paragraph thanks to
- Daryle Walker)
- * [13.8] How do I create a subscript operator for a Matrix class?
- (added return type to main(); added parameters to the instantiation of m in
- main() thanks to Boris Pulatov)
- * [13.10] Should I design my classes from the outside (interfaces first) or
- from the inside (data first)?
- (added an admonition to not "roll your own" container classes)
- * [15.2] Why does my program go into an infinite loop when someone enters an
- invalid input character?
- (added return type to main())
- * [15.4] Why does my input seem to process past the end of file?
- (strengthened the message with another example)
- * [15.6] How can I provide printing for my class Fred?
- (added return type to main())
- * [15.7] How can I provide input for my class Fred?
- (added return type to main())
- * [15.10] Why can't I open a file in a different directory such as
- "..\test.dat"?
- (added return type to main())
- * [16.6] How can I convince my (older) compiler to automatically check new to
- see if it returns NULL?
- (added return type to main())
- * [16.19] How can I force objects of my class to always be created via new
- rather than as locals or global/static objects?
- (added return type to main())
- * [18.12] Why does the compiler allow me to change an int after I've pointed
- at it with a const int*?
- (added return type to main())
- * [18.13] Does "const Fred* p" mean that *p can't change?
- (added return type to main())
- * [21.2] Derived* --> Base* works OK; why doesn't Derived** --> Base** work?
- (added return type to main(); added methods openGasCap() and
- fireNuclearMissle() -- makes the example more exciting)
- * [21.4] Is an array of Derived a kind-of array of Base?
- (added return type to main())
- * [24.4] Should I pointer-cast from a private derived class to its base class?
- (changed PrivateDer to PrivatelyDer in last paragraph)
- * [24.6] What are the access rules with private and protected inheritance?
- (rewritten with the using syntax; thanks to Stephen Vance)
- * [29.2] How can I include a standard C header file in my C++ code?
- (added return type to main())
- * [29.3] How can I include a non-system C header file in my C++ code?
- (added return type to main())
- * [29.4] How can I modify my own C header files so it's easier to #include
- them in C++ code?
- (added return type to main())
- * [29.5] How can I call a non-system C function f(int,char,float) from my C++
- code?
- (added return type to main())
- * [30.2] How do I pass a pointer to member function to a signal handler, X
- event callback, etc?
- (added return type to main())
- * [31.1] How can I make a perl-like associative array in C++?
- (added return type to main())
- * [31.5] What's the syntax / semantics for a "function template"?
- (added return type to main())
- * [31.6] What's the syntax / semantics for a "class template"?
- (added return type to main())
- * [33.1] Where can I download a free C++ compiler?
- (fixed the URL)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (added Edison Design Group C++ thanks to Matt Page)
- * [34.8] Why is floating point so inaccurate? Why doesn't this print 0.43?
- (added return type to main())
- * [35.2] Are there any pretty-printers that reformat C++ source code?
- (added Artistic Style thanks to Philipp Berndt, fixed the URL for C++2LaTeX
- thanks to Vinay Kumar Nallamothu, fixed the URL for C-Clearly thanks to Bill
- Robertson; fixed the plaintext version (the "grind" definition didn't show up
- there) thanks to Nimrod Zimerman)
-
- ==============================================================================
-
- [4.4] What updates were made for the 07/99 release?
-
- New FAQs:
- * [4.4] What updates were made for the 07/99 release?
- * [33.1] Where can I download a free C++ compiler?
-
- Changed FAQs:
- * [1.6] C++-FAQ-Lite != C++-FAQ-Book
- (updated due to the Second Edition of the book)
- * [2.1] Where's the closest mirror site to access this document?
- (added Ireland mirror site: snet.wit.ie/GreenSpirit/c++-faq-lite)
- * [2.2] How can I get a Copy of all the HTML files of C++ FAQ Lite so I can
- read them Off-Line?
- (added "Windows 98" to last paragraph)
- * [3.1] Is there a C++ FAQ Book in addition to the C++ FAQ Lite?
- (updated due to the Second Edition of the book)
- * [3.3] How can I download an electronic copy of the C++ FAQ Book?
- (fixed URL of book at Addison-Wesley, added amazon.com URL)
- * [6.5] Who uses C++?
- (corrected the growth rate)
- * [6.8] Are virtual functions (dynamic binding) central to OO/C++?
- (added STL and generic programming)
- * [6.12] Where can I get a copy of the ANSI/ISO C++ standard?
- (added new ways to get a copy via the web)
- * [12.3] OK, OK, already; I'll handle self-assignment. How do I do it?
- (tightened the wording of the last paragraph thanks to Andy Glew)
- * [15.3] How does that funky while (cin >> foo) syntax work?
- (corrected a serious bug: changed operator bool() to operator void*();
- thanks to Rajinikanth Sivalingam)
- * [16.22] How do I provide reference counting with copy-on-write semantics for
- a hierarchy of classes?
- (fixed a bug by making Fred a friend of Fred::Data)
- * [18.9] What is a "const member function"?
- (changed "const pointer" to "pointer-to-const" thanks to Saieb Khalil)
- * [20.4] When should my destructor be virtual?
- (changed "explicit destructor" to "explicitly defined destructor" to avoid
- confusion with the explicit keyword used with constructors)
- * [23.2] Should a derived class replace ("override") a non-virtual function
- from a base class?
- (reworded first full paragraph)
- * [25.11] Are there any other sources of coding standards?
- (removed the URL for the anti-guide (thanks to Bill Seymour for letting me
- know that the anti-guide disappeared))
- * [26.5] What are some best-of-breed C++ morality guides?
- (updated info on C++ FAQs book because of its Second Edition)
- * [26.6] What are some best-of-breed C++ legality guides?
- (fixed the ISBN for Bjarne Stroustrup's book)
- * [28.1] What is value and/or reference semantics, and which is best in C++?
- (wordsmithing changes thanks to Lance Ware)
- * [31.3] How can I insert/access/change elements from a linked
- list/hashtable/etc?
- (reworded item #3 thanks to John Millaway)
- * [32.3] How can I find a Fred object in an STL container of Fred* such as
- vector<Fred*>?
- (fixed a typo in the code thanks to Scott Maxwell and Bill Sloan)
- * [33.4] How can I decompile an executable program back into C++ source code?
- (wordsmithing changes thanks to Lance Ware)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (corrected the URL for KAI C++ and added Rational APEX C/C++ thanks to Kevin
- Broadey; corrected the URL for Borland C++ FAQ thanks to Kent Reisdorph
- <kentr@turbopower.com> and Michael J. Reeves <mreeves@ns.net>)
- * [34.5] Does C++ have new scoping rules for for loops?
- (wordsmithing changes thanks to Lance Ware)
-
- ==============================================================================
-
- [4.5] What updates were made for the 06/98 release?
-
- New FAQs:
- * [4.5] What updates were made for the 06/98 release?
- * [10.14] How can I handle a constructor that fails?
-
- Changed FAQs:
- * [32.9] Where can I get tons and tons of more information on C++ class
- libraries?
- (fixed the URL)
-
- ==============================================================================
-
- [4.6] What updates were made for the 05/98 release?
-
- Global changes:
- * Removed the grey background color on the HTML version. It now displays in
- the Web Browser's own preferences.
-
- New FAQs:
- * [1.5] Trademarks
- * [2.4] Why is the download via email? Why not via ftp?
- * [2.6] Where can I download a Portuguese translation of this on-line
- document?
- * [4.6] What updates were made for the 05/98 release?
- * [10.6] Should my constructors use "initialization lists" or "assignment"?
- * [26.8] But those books are too advanced for me since I've never used any
- programming language before; is there any hope for me?
- * [33.2] Where can I get more information on using MFC and Visual C++?
-
- Changed FAQs:
- * [2.2] How can I get a Copy of all the HTML files of C++ FAQ Lite so I can
- read them Off-Line?
- (made it clearer why there is no FTP or HTTP address for downloading the
- FAQ)
- * [2.3] How can I get a Copy of all the "plaintext" files of C++ FAQ Lite so I
- can read them Off-Line?
- (made it clearer why there is no FTP or HTTP address for downloading the
- FAQ)
- * [6.11] Is C++ standardized?
- (rewrote now that the standard is here)
- * [6.12] Where can I get a copy of the ANSI/ISO C++ standard?
- (rewrote now that the standard is here)
- * [16.17] But the above Matrix class is specific to Fred! Isn't there a way to
- make it generic?
- (fixed Matrix's ctor thanks to Dhavide Aruliah)
- * [16.21] How do I provide reference counting with copy-on-write semantics?
- (fixed Fred's default ctor thanks to Scott Harris)
- * [32.3] How can I find a Fred object in an STL container of Fred* such as
- vector<Fred*>?
- (changed operator==() to operator()() thanks to Ali Tajeldin)
- * [32.4] Where can I get help on how to use STL?
- (added the URL for the STL FAQ)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (corrected the URL for Borland C++ & HP C++; added GNU C++, Intel Reference
- C++, KAI C++, and Portland Group C++)
- * [35.2] Are there any pretty-printers that reformat C++ source code?
- (added a URL for "GNU indent")
-
- ==============================================================================
-
- [4.7] What updates were made for the 09/97 release?
-
- New FAQs:
- * [4.7] What updates were made for the 09/97 release?
- * [10.11] What's the "static initialization order fiasco"?
- * [10.12] How do I prevent the "static initialization order fiasco"?
- * [10.13] How do I prevent the "static initialization order fiasco" for my
- static data members?
- * [16.17] But the above Matrix class is specific to Fred! Isn't there a way to
- make it generic?
-
- Changed FAQs:
- * [1.3] Copying Permissions
- (clarified)
- * [5.1] What does IMHO mean? (or IMO, IMNSHO, FWIW, OTOH, etc.)?
- (added silly acronym-laden comment at the bottom (adapted from e-mail from
- Erik Corry)
- * [16.16] But the previous FAQ's code is SOOOO tricky and error prone! Isn't
- there a simpler way?
- (fixed some inconsistencies between FredMatrix and Matrix thanks to Jeff
- Baker)
- * [16.20] How do I do simple reference counting?
- (fixed FredPtr's constructor thanks to Chichiang Wan)
- * [23.3] What's the meaning of, Warning: Derived::f(float) hides Base::f(int)?
- (rewritten with the using syntax; thanks to Matt Seitz)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (corrected the URL for Symantec C++
- <http://www.symantec.com/scpp/index_product.html> thanks to Michel Joly de
- Lotbiniere and added the URL for HP C++ thanks to David Green)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (corrected the URL for Microsoft Visual C++ thanks to Leila Rannanjarvi, and
- added the URL for Sun C++ thanks to Aryan Mirsepassi)
- * [35.2] Are there any pretty-printers that reformat C++ source code?
- (added information about tgrind)
-
- ==============================================================================
-
- [4.8] What updates were made for the 01/97 release?
-
- Global changes:
- * Added the (much requested!) one-click download feature[2.2]. This
- automagically sends you a copy of the entire FAQ so you can browse off-line.
- There's a similar feature to get a copy of the "plaintext" version of the
- FAQ[2.3].
- * Removed those pesky "hit counters" from each HTML page.
- * Added nifty forward and backward links just after each FAQ.
- * Added more nifty navigation aids at the bottom of each page.
- * Renamed section [6] from "Management Issues" to "Big Picture Issues."
-
- New FAQs:
- * [4.8] What updates were made for the 01/97 release?
- * [15.2] Why does my program go into an infinite loop when someone enters an
- invalid input character?
- * [15.3] How does that funky while (cin >> foo) syntax work?
- * [16.16] But the previous FAQ's code is SOOOO tricky and error prone! Isn't
- there a simpler way?
- * [25.5] Is the ?: operator evil since it can be used to create unreadable
- code?
-
- Changed FAQs:
- * [1.3] Copying Permissions
- (simplified)
- * [2.1] Where's the closest mirror site to access this document?
- (removed the "USA-2" site)
- * [2.2] How can I get a Copy of all the HTML files of C++ FAQ Lite so I can
- read them Off-Line?
- (rewrote and added a one-click feature to get .zip, .tar.Z or .tar.gz
- format)
- * [2.3] How can I get a Copy of all the "plaintext" files of C++ FAQ Lite so I
- can read them Off-Line?
- (rewrote and added a one-click feature to get .zip, .tar.Z or .tar.gz
- format)
- * [5.1] What does IMHO mean? (or IMO, IMNSHO, FWIW, OTOH, etc.)?
- (added KUTGW (thanks to Bengt Richter))
- * [15.6] How can I provide printing for my class Fred?
- (added note about cascading operator<< calls)
- * [15.7] How can I provide input for my class Fred?
- (added note about cascading operator<< calls)
- * [16.6] How can I convince my (older) compiler to automatically check new to
- see if it returns NULL?
- (fixed bugs: new handlers don't take arguments, thanks to Scott Aaron;
- changed set_new_hanlder to set_new_handler, thanks to Peter Andersson)
- * [16.15] How do I allocate multidimensional arrays using new?
- (rewritten and expanded with a rectangular-matrix case)
- * [18.1] What is "const correctness"?
- (rewrote because of helpful feedback from Nor Jaidi)
- * [21.6] Is a Circle a kind-of an Ellipse?
- (added a caveat that setSize(x,y) isn't sacred)
- * [21.7] Are there other options to the "Circle is/isnot kind-of Ellipse"
- dilemma?
- (added a caveat that setSize(x,y) isn't sacred)
- * [21.8] But I have a Ph.D. in Mathematics, and I'm sure a Circle is a kind of
- an Ellipse! Does this mean Marshall Cline is stupid? Or that C++ is stupid?
- Or that OO is stupid?
- (added a caveat that setSize(x,y) isn't sacred)
- * [23.1] When my base class's constructor calls a virtual function, why
- doesn't my derived class's override of that virtual function get invoked?
- (rewrote)
- * [29.8] How can I pass an object of a C++ class to/from a C function?
- (added #ifndef FRED_H / #define FRED_H to code)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (added HP C++)
- * [35.4] Where can I get OS-specific questions answered (e.g., BC++, DOS,
- Windows, etc)?
- (added Borland C++ URLs thanks to Simon Edlund)
-
- ==============================================================================
-
- [4.9] What updates were made for the 11/96 release?
-
- New FAQs:
- * [2.2] How can I get a Copy of all the HTML files of C++ FAQ Lite so I can
- read them Off-Line?
- * [4.9] What updates were made for the 11/96 release?
- * [20.3] What's the difference between how virtual and non-virtual member
- functions are called?
- * [33.3] How do I display text in the status bar using MFC?
- (with the help of Paul Ganney)
-
- Changed FAQs:
- * [8.4] How can you reseat a reference to make it refer to a different object?
- (changed last line from "pointer to const" to "const pointer" thanks to
- Neelesh Pandit)
- * [25.11] Are there any other sources of coding standards?
- (rewrote and added more URLs)
- * [33.8] If name mangling was standardized, could I link code compiled with
- compilers from different compiler vendors?
- (reworded and added v-table and v-pointer references[20.3])
-
- ==============================================================================
-
- [4.10] What updates were made for the 10/96 release?
-
- New FAQs:
- * [4.10] What updates were made for the 10/96 release?
-
- Changed FAQs:
- * [5.8] Which newsgroup should I post my questions?
- (added comp.sys.mac.programmer.* and comp.sys.mac.oop.*)
- * [16.6] How can I convince my (older) compiler to automatically check new to
- see if it returns NULL?
- (added comments on constructors of globals; thanks to William Carroll)
- * [25.11] Are there any other sources of coding standards?
- (added URLs)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (added URL for Metrowerks and Watcom compilers)
-
- ==============================================================================
-
- [4.11] What updates were made for the 09/96 release?
-
- New FAQs:
- * [4.11] What updates were made for the 09/96 release?
- * [5.1] What does IMHO mean? (or IMO, IMNSHO, FWIW, OTOH, etc.)?
- * [5.2] How do I get comp.lang.c++ to do my homework problem for me?
- * [5.3] What should I do if I see someone else posting a homework problem?
- (with the help of Phil Staite)
- * [18.4] What does "const Fred* p" mean?
- * [18.5] What's the difference between "const Fred* p", "Fred* const p" and
- "const Fred* const p"?
- * [18.6] What does "const Fred& x" mean?
- * [18.7] Does "Fred& const x" make any sense?
- * [18.8] What does "Fred const& x" mean?
- * [18.13] Does "const Fred* p" mean that *p can't change?
- * [25.11] Are there any other sources of coding standards?
- * [33.4] How can I decompile an executable program back into C++ source code?
- (with the help of Phil Staite)
-
- Changed FAQs:
- * [8.4] How can you reseat a reference to make it refer to a different object?
- (added a cross reference regarding pointer to const[18.4])
- * [9.4] How do you tell the compiler to make a non-member function inline?
- (strengthened the "Note:" at the end)
- * [16.19] How can I force objects of my class to always be created via new
- rather than as locals or global/static objects?
- (reworded and added a paragraph on using friend[14] to soften the original
- goal)
- * [16.21] How do I provide reference counting with copy-on-write semantics?
- (added links to the self assignment[12.1] discussion)
- * [16.22] How do I provide reference counting with copy-on-write semantics for
- a hierarchy of classes?
- (added links to the self assignment[12.1] discussion)
- * [17.2] How should I handle resources if my constructors may throw
- exceptions?
- (added cross-references for reference-counted[16.20] and remote[13.3]
- smart-pointers)
- * [21.2] Derived* --> Base* works OK; why doesn't Derived** --> Base** work?
- (fixed a bug with help from William Wu)
- * [22.4] What is a "pure virtual" member function?
- (reworded)
- * [32.4] Where can I get help on how to use STL?
- (fixed the URL for Kenny Zalewski's STL guide)
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
- (added URLs for Silicon Graphics and Symantec compilers)
- * [35.2] Are there any pretty-printers that reformat C++ source code?
- (added a URL for "V Communications")
-
- ==============================================================================
-
- [4.12] What updates were made for the 08/96 release?
-
- Global changes:
- * Recently added/changed FAQs are now chained together using hyper-links
- (mainly for those who want to find out what has changed since the last time
- they read this document; only available in the HTML version)
- * Recently added FAQs are now decorated with [NEW!] ("recently" = "in the
- current or previous release")
- * Recently changed FAQs are now decorated with [UPDATED!] ("recently" = "in
- the current or previous release")
- * The look-and-feel of hyper-linked cross references is changed (NOTE: this
- change ONLY shows up in the HTML version)
- - The old look-and-feel "looks like this[4.12]"
- - The new look-and-feel "looks like this[4.12]"
- * Added section [12] Assignment operators
- * Added section [26] Learning OO/C++
-
- New FAQs:
- * [4.12] What updates were made for the 08/96 release?
- * [7.3] When is an interface "good"?
- * [7.4] What is encapsulation?
- * [7.5] How does C++ help with the tradeoff of safety vs. usability?
- * [9.2] How can inline functions help with the tradeoff of safety vs. speed?
- * [12.1] What is "self assignment"?
- * [12.2] Why should I worry about "self assignment"?
- * [12.3] OK, OK, already; I'll handle self-assignment. How do I do it?
- * [13.3] What are some examples of operator overloading?
- * [15.10] Why can't I open a file in a different directory such as
- "..\test.dat"?
- * [26.1] What is mentoring?
- * [26.2] Should I learn C before I learn OO/C++?
- * [26.3] Should I learn Smalltalk before I learn OO/C++?
- * [26.4] Should I buy one book, or several?
- * [26.5] What are some best-of-breed C++ morality guides?
- * [26.6] What are some best-of-breed C++ legality guides?
- * [26.7] Are there other OO books that are relevant to OO/C++?
- * [33.5] Where can I get information about the C++ compiler from {Borland,
- IBM, Microsoft, Semantic, Sun, etc.}?
-
- Changed FAQs:
- * [6.4] Is C++ better than Ada? (or Visual Basic, C, FORTRAN, Pascal,
- Smalltalk, or any other language?)
- (reworded the last paragraph)
- * [6.6] How long does it take to learn OO/C++?
- (added management-level hints for training developers in OO/C++)
- * [9.3] Why should I use inline functions? Why not just use plain old #define
- macros?
- (moved)
- * [13.4] But operator overloading makes my class look ugly; isn't it supposed
- to make my code clearer?
- (rewritten)
- * [13.8] How do I create a subscript operator for a Matrix class?
- (fixed a bug: "double** data_" is now "double* data_")
- * [25.9] Are there any lint-like guidelines for C++?
- (added links to the self assignment[12.1] discussion)
- * [26.6] What are some best-of-breed C++ legality guides?
- (fixed the ISBN for Stan Lippman's book)
- * [27.1] What's the difference between C++ and Smalltalk?
- (rewritten)
- * [32.5] How can you tell if you have a dynamically typed C++ class library?
- (moved from the section on Smalltalk[27])
- * [32.6] What is the NIHCL? Where can I get it?
- (moved from the section on Smalltalk[27])
- * [32.9] Where can I get tons and tons of more information on C++ class
- libraries?
- (updated the URL)
- * [34.4] Why can't the compiler find my header file in
- #include "c:\test.hpp" ?
- (updated to refer to [15.10])
-
- ==============================================================================
-
- [4.13] What updates were made for the 07/96 release?
-
- Global changes:
- * Created an extensive subject index
- * Added hyper-linked internal cross references throughout (mainly useful for
- the HTML version)
- * Changed the name of the document from On-Line C++ FAQs to C++ FAQs Lite
- * Created section [23] Inheritance -- what your mother never told you
- * Split sections [10] Constructors and [11] Destructors into two distinct
- sections
- * Major reorganization of sections [19] Inheritance -- basics, [20]
- Inheritance -- virtual functions, [21] Inheritance -- proper inheritance and
- substitutability, and [22] Inheritance -- abstract base classes (ABCs)
- * Added example code throughout section [29] How to mix C and C++
-
- New FAQs:
- * [4.13] What updates were made for the 07/96 release?
- * [5.5] What do I do if someone else posts a question that's already in the
- FAQ?
- * [5.6] What makes a good Subject: line?
- * [6.8] Are virtual functions (dynamic binding) central to OO/C++?
- * [6.9] I'm from Missouri. Can you give me a simple reason why virtual
- functions (dynamic binding) make a big difference?
- * [7.6] How can I prevent other programmers from violating encapsulation by
- seeing the private parts of my class?
- * [7.7] Is Encapsulation a Security device?
- * [10.4] Is the default constructor for Fred always Fred::Fred()?
- * [10.5] Which constructor gets called when I create an array of Fred objects?
- * [10.8] What is the "Named Constructor Idiom"?
- * [10.9] Why can't I initialize my static member data in my constructor's
- initialization list?
- * [11.2] What's the order that local objects are destructed?
- * [11.3] What's the order that objects in an array are destructed?
- * [11.4] Can I overload the destructor for my class?
- * [11.5] Should I explicitly call a destructor on a local variable?
- * [11.6] What if I want a local to "die" before the close } of the scope in
- which it was created? Can I call a destructor on a local if I really want
- to?
- * [11.7] OK, OK already; I won't explicitly call the destructor of a local;
- but how do I handle the above situation?
- * [11.8] What if I can't wrap the local in an artificial block?
- * [11.9] But can I explicitly call a destructor if I've allocated my object
- with new?
- * [11.10] What is "placement new" and why would I use it?
- * [11.11] When I write a destructor, do I need to explicitly call the
- destructors for my member objects?
- * [13.6] Can I overload operator== so it lets me compare two char[] using a
- string comparison?
- * [13.8] How do I create a subscript operator for a Matrix class?
- * [13.10] Should I design my classes from the outside (interfaces first) or
- from the inside (data first)?
- * [15.7] How can I provide input for my class Fred?
- * [16.5] Do I need to check for NULL after p = new Fred()?
- * [16.6] How can I convince my (older) compiler to automatically check new to
- see if it returns NULL?
- * [16.7] Do I need to check for NULL before delete p?
- * [16.8] What are the two steps that happen when I say delete p?
- * [16.9] In p = new Fred(), does the Fred memory "leak" if the Fred
- constructor throws an exception?
- * [16.12] Can I drop the [] when deleteing array of some built-in type (char,
- int, etc)?
- * [16.13] After p = new Fred[n], how does the compiler know there are n
- objects to be destructed during delete[] p?
- * [16.20] How do I do simple reference counting?
- * [16.21] How do I provide reference counting with copy-on-write semantics?
- * [16.22] How do I provide reference counting with copy-on-write semantics for
- a hierarchy of classes?
- * [17.3] How do I change the string-length of an array of char to prevent
- memory leaks even if/when someone throws an exception?
- * [18.12] Why does the compiler allow me to change an int after I've pointed
- at it with a const int*?
- * [22.5] How do you define a copy constructor or assignment operator for a
- class that contains a pointer to a (abstract) base class?
- * [23.4] What does it mean that the "virtual table" is an unresolved external?
- * [25.10] Which is better: identifier names that_look_like_this or identifier
- names thatLookLikeThis?
- (with the help of James Robinson)
- * [29.1] What do I need to know when mixing C and C++ code?
- * [30.5] How can I avoid syntax errors when calling a member function using a
- pointer-to-member-function?
- * [31.1] How can I make a perl-like associative array in C++?
- * [32.3] How can I find a Fred object in an STL container of Fred* such as
- vector<Fred*>?
- * [32.9] Where can I get tons and tons of more information on C++ class
- libraries?
- * [33.6] How do compilers use "over-allocation" to remember the number of
- elements in an allocated array?
- * [33.7] How do compilers use an "associative array" to remember the number of
- elements in an allocated array?
- * [34.4] Why can't the compiler find my header file in
- #include "c:\test.hpp" ?
- * [34.5] Does C++ have new scoping rules for for loops?
-
- Changed FAQs:
- * [5.4] How can I find out about general netiquette so I don't embarrass
- myself?
- (rewritten)
- * [5.7] How do I post a question about code that doesn't work correctly?
- (rewritten)
- * [7.8] What's the difference between the keywords struct and class?
- (rewritten)
- * [10.10] Why are classes with static data members getting linker errors?
- (rewritten)
- * [11.12] When I write a derived class's destructor, do I need to explicitly
- call the destructor for my base class?
- (added example code to illustrate the compiler's automagic calls to
- destructors of member objects and base class subobjects)
- * [15.6] How can I provide printing for my class Fred?
- (added example code to illustrate operator<< on an ostream)
- * [15.8] How can I provide printing for an entire hierarchy of classes?
- (moved from the section on Abstraction[22])
- * [16.19] How can I force objects of my class to always be created via new
- rather than as locals or global/static objects?
- (added a reference to the Named Constructor Idiom[10.8])
- * [29.2] How can I include a standard C header file in my C++ code?
- (rewritten)
- * [29.3] How can I include a non-system C header file in my C++ code?
- (rewritten)
- * [29.4] How can I modify my own C header files so it's easier to #include
- them in C++ code?
- (rewritten)
- * [33.10] Is there a yacc-able C++ grammar?
- (updated the URL for the yacc-able C++ grammar)
- * [35.2] Are there any pretty-printers that reformat C++ source code?
- (added "C-Clearly" and GNU indent to the list of pretty-printers)
-
- ==============================================================================
-
- [4.14] What updates were made for the 06/96 release?
-
- New FAQs:
- * [4.14] What updates were made for the 06/96 release?
- * [10.2] Is there any difference between List x; and List x();?
- * [34.8] Why is floating point so inaccurate? Why doesn't this print 0.43?
- (with the help of Phil Staite)
-
- Changed FAQs:
- * [2.1] Where's the closest mirror site to access this document?
- (added Finland mirror site: www.utu.fi/~sisasa/oasis/cppfaq/)
- * [3.1] Is there a C++ FAQ Book in addition to the C++ FAQ Lite?
- (fixed URL of book at Addison-Wesley)
- * [3.3] How can I download an electronic copy of the C++ FAQ Book?
- (fixed URL of book at Addison-Wesley)
- * [18.1] What is "const correctness"?
- (added info on what happens when you try to pass a const parameter to a
- non-const function)
- * [20.4] When should my destructor be virtual?
- (added the nitty-gritty rule for when you need to have a virtual destructor)
- * [21.4] Is an array of Derived a kind-of array of Base?
- (fixed bug in code)
- * [22.3] What is an ABC?
- (reworded)
- * [22.4] What is a "pure virtual" member function?
- (reworded)
- * [28.4] Should I normally use pointers to freestore allocated objects for my
- data members, or should I use "composition"?
- (reworded)
- * [29.8] How can I pass an object of a C++ class to/from a C function?
- (fixed a bug in the code)
- * [31.4] What's the idea behind templates?
- (reworded)
- * [31.6] What's the syntax / semantics for a "class template"?
- (reworded)
- * [35.1] Is there a TeX or LaTeX macro that fixes the spacing on "C++"?
- (added a new LaTeX macro)
- * [35.2] Are there any pretty-printers that reformat C++ source code?
- (fixed URL of C++2LaTeX)
-
- ==============================================================================
-
- [4.15] What updates were made for the 05/96 release?
-
- Updated everything. Transformed the source from raw text to HTML.
- Reorganized, reworded, expanded, added example code, etc, etc.
-
- ==============================================================================
-
- [4.16] What updates were made for the 04/96 release?
-
- New FAQs:
- * [4.16] What updates were made for the 04/96 release?
- * [29.2] How can I include a standard C header file in my C++ code?
- * [29.3] How can I include a non-system C header file in my C++ code?
- * [29.4] How can I modify my own C header files so it's easier to #include
- them in C++ code?
-
- Changed FAQs:
- * [2.1] Where's the closest mirror site to access this document?
- (added European mirror site:
- www.informatik.uni-konstanz.de/~kuehl/cpp/cppfaq.htm)
- * [16.14] Is it legal (and moral) for a member function to say delete this?
- (rewritten)
- * [22.4] What is a "pure virtual" member function?
- (rewritten)
-
- ==============================================================================
-
- [4.17] What updates were made for the 03/96 release?
-
- New FAQs:
- * [4.17] What updates were made for the 03/96 release?
- * [6.4] Is C++ better than Ada? (or Visual Basic, C, FORTRAN, Pascal,
- Smalltalk, or any other language?)
- * [31.2] How can I build a <favorite container> of objects of different types?
- (with the help of Phil Staite)
-
- Changed FAQs:
- * [2.3] How can I get a Copy of all the "plaintext" files of C++ FAQ Lite so I
- can read them Off-Line?
- (added URL ftp://rtfm.mit.edu/pub/usenet-by-group/comp.lang.c++/)
- * [6.12] Where can I get a copy of the ANSI/ISO C++ standard?
- (fixed the URL for the ANSI/ISO-C++ Committee Draft)
- * [15.1] Why should I use <iostream.h> instead of the traditional <stdio.h>?
- (reworded)
- * [16.2] Can I free() pointers allocated with new? Can I delete pointers
- allocated with malloc()?
- (added an admonition not to mix new and free() or malloc() and delete)
- * [25.1] What are some good C++ coding standards?
- (reworded)
- * [25.2] Are coding standards necessary? Are they sufficient?
- (reworded)
- * [25.3] Should our organization determine coding standards from our C
- experience?
- (reworded)
- * [25.9] Are there any lint-like guidelines for C++?
- (reworded)
- * [27.3] Which is a better fit for C++: "static typing" or "dynamic typing"?
- (updated info on dynamic_cast and typeid())
- * [35.2] Are there any pretty-printers that reformat C++ source code?
- (fixed URL of C++2LaTeX)
-
- ==============================================================================
-
- [4.18] What updates were made for the 09/95 release?
-
- New FAQs:
- * [4.18] What updates were made for the 09/95 release?
- * [15.9] How can I "reopen" cin and cout in binary mode under DOS and/or OS/2?
- * [32.4] Where can I get help on how to use STL?
- * [32.7] Where can I ftp the code that accompanies "Numerical Recipes"?
- * [32.8] Why is my executable so large?
-
- Changed FAQs:
- * [6.12] Where can I get a copy of the ANSI/ISO C++ standard?
- (added info on FTP access for the ANSI/ISO-C++ Committee Draft)
- * [8.3] What happens if you return a reference?
- (fixed a bug (variable i was not declared))
- * [16.15] How do I allocate multidimensional arrays using new?
- (reworded)
- * [32.2] Where can I get a copy of "STL"?
- (reworded)
-
- ==============================================================================
-
- [4.19] What updates were made for the 06/95 release?
-
- New FAQs:
- * [4.19] What updates were made for the 06/95 release?
- * [16.15] How do I allocate multidimensional arrays using new?
- (with the help of Doug Shapter)
- * [30.3] Why do I keep getting compile errors (type mismatch) when I try to
- use a member function as an interrupt service routine?
-
- Changed FAQs:
- * [6.12] Where can I get a copy of the ANSI/ISO C++ standard?
- (fixed the US-Mail access for the ANSI/ISO-C++ Committee Draft)
- * [16.19] How can I force objects of my class to always be created via new
- rather than as locals or global/static objects?
- (rewritten)
-
- ==============================================================================
-
- [4.20] What updates were made for the 04/95 release?
-
- New FAQs:
- * [4.20] What updates were made for the 04/95 release?
- * [35.4] Where can I get OS-specific questions answered (e.g., BC++, DOS,
- Windows, etc)?
-
- Changed FAQs:
- * [32.6] What is the NIHCL? Where can I get it?
- (fixed the FTP address)
-
- ==============================================================================
-
- [4.21] What updates were made for the 03/95 release?
-
- New FAQs:
- * [4.21] What updates were made for the 03/95 release?
- * [15.4] Why does my input seem to process past the end of file?
- * [15.5] Why is my program ignoring my input request after the first
- iteration?
- * [16.14] Is it legal (and moral) for a member function to say delete this?
-
- Changed FAQs:
- * [35.3] Is there a C++-mode for GNU emacs? If so, where can I get it?
- (updated the information on cc-mode.el)
-
- ==============================================================================
-
- [4.22] What updates were made for the 01/95 release?
-
- New FAQs:
- * [2.5] Where can I download a Chinese translation of this on-line document?
- * [4.22] What updates were made for the 01/95 release?
-
- ==============================================================================
-
- [4.23] What updates were made for the 12/94 release?
-
- New FAQs:
- * [4.23] What updates were made for the 12/94 release?
- * [32.2] Where can I get a copy of "STL"?
- * [33.8] If name mangling was standardized, could I link code compiled with
- compilers from different compiler vendors?
-
- Changed FAQs:
- * [24.3] Which should I prefer: composition or private inheritance?
- (reworded)
-
- ==============================================================================
-
- [4.24] What updates were made for the 11/94 release?
-
- New FAQs:
- * [3.1] Is there a C++ FAQ Book in addition to the C++ FAQ Lite?
- * [3.2] Is there a big difference between C++ FAQ Lite and C++ FAQ Book?
- * [3.3] How can I download an electronic copy of the C++ FAQ Book?
- * [4.24] What updates were made for the 11/94 release?
-
- ==============================================================================
-
- [4.25] What updates were made for the 08/94 release?
-
- Rewrote most of the answers to provide general cleanup. Changed the quotation
- marks to "..." rather than `...' and/or ``...''. Sample code lines now start
- with a tab (no other lines starts with a tab). Everything was edited; minor
- modifications everywhere.
-
- New FAQs:
- * [4.25] What updates were made for the 08/94 release?
- * [18.10] What do I do if I want to update an "invisible" data member inside a
- const member function?
- * [27.3] Which is a better fit for C++: "static typing" or "dynamic typing"?
-
- ==============================================================================
-
- [4.26] What updates were made before 08/94?
-
- This document was originally written in 1991. I have no record of the specific
- changes that were made until 8/94.
-
- ==============================================================================
-
- --
- Marshall Cline / 972-931-9470 / mailto:cline@parashift.com
-