FAQs in section [4]:
[4.1] What updates were made for the 07/00 release?
[Recently created (on 7/00). Click here to go to the next FAQ in the "chain" of recent changes.]
Global changes:
- Moved the main FAQ site to www.parashift.com/c++-faq-lite/. (This was unfortunately
necessary due to a business issue involving AT&T and the previous web hosting
company, Cerf-Net.)
New FAQs:
Changed FAQs:
- [2.5] Where can I download a Chinese translation of this on-line
document?
(updated the URL)
- [3.1] Is there a C++ FAQ Book in addition to the C++ FAQ Lite?
(added BookPool.com and AllDirect.com thanks to Stan Brown, plus reorganized)
- [3.2] Is there a big difference between C++ FAQ Lite
and C++ FAQ Book?
(changed 'much' to 'many' thanks to Stan Brown)
- [6.5] Who uses C++?
(rewrote)
- [6.8] Are virtual functions (dynamic binding) central to
OO/C++?
(inserted "the" before "difference" thanks to Stan Brown and reworded references to STL)
- [6.11] Is C++ standardized?
(changed "has been finalized" to "was finalized" thanks to Stan Brown)
- [6.12] Where can I get a copy of the ANSI/ISO C++ standard?
(added URLs to free copies of CD2)
- [9.3] Why should I use inline functions? Why not just use
plain old #define macros?
(rewrote the sentence on #define being evil)
- [10.5] Which constructor gets called when I create an
array of Fred objects?
(changed so it uses new-style headers and the std:: syntax and reworded references to STL)
- [10.8] What is the "Named Constructor Idiom"?
(fixed a typo (Fred vs. Point) in the prose thanks to Roy LeCates)
- [12.3] OK, OK, already; I'll handle self-assignment. How do
I do it?
(reworded the last paragraph)
- [13.3] What are some examples of operator overloading?
(changed so it uses new-style headers and the std:: syntax)
- [13.6] Can I overload operator== so it lets
me compare two char[] using a string comparison?
(changed so it uses new-style headers and the std:: syntax)
- [13.8] How do I create a subscript operator for a
Matrix class?
(changed so it uses new-style headers and the std:: syntax)
- [13.10] Should I design my classes from the outside
(interfaces first) or from the inside (data first)?
(changed so it uses new-style headers and the std:: syntax and reworded references to STL)
- [15.1] Why should I use <iostream> instead of the
traditional <cstdio>?
(renamed "subclassable" to "inheritable" and revamped to use new-style headers)
- [15.2] Why does my program go into an infinite loop when
someone enters an invalid input character?
(changed so it uses new-style headers and the std:: syntax)
- [15.3] How does that funky while (std::cin >> foo) syntax
work?
(changed so it uses new-style headers and the std:: syntax)
- [15.4] Why does my input seem to process past the end of file?
(changed so it uses new-style headers and the std:: syntax)
- [15.5] Why is my program ignoring my input request
after the first iteration?
(changed so it uses new-style headers and the std:: syntax)
- [15.6] How can I provide printing for my class Fred?
(changed so it uses new-style headers and the std:: syntax)
- [15.8] How can I provide input for my class Fred?
(changed so it uses new-style headers and the std:: syntax)
- [15.9] How can I provide printing for an entire hierarchy of
classes?
(changed so it uses new-style headers and the std:: syntax)
- [15.10] How can I "reopen" std::cin and std::cout in binary
mode under DOS and/or OS/2?
(changed so it uses new-style headers and the std:: syntax)
- [15.11] Why can't I open a file in a different directory
such as "..\test.dat"?
(changed so it uses new-style headers and uses the std:: syntax)
- [16.5] Do I need to check for NULL after p = new Fred()?
(changed so it uses new-style headers and the std:: syntax)
- [16.6] How can I convince my (older) compiler to
automatically check new to see if it returns NULL?
(changed so it uses new-style headers and uses the std:: syntax)
- [16.13] After p = new Fred[n], how does the
compiler know there are n objects to be destructed during delete[] p?
(changed "popluar" to "popular" thanks to Fabrice Clerc)
- [16.15] How do I allocate multidimensional arrays using new?
(fixed a leak in the third manipulateArray() by moving another for loop into the try block)
- [16.16] But the previous FAQ's code is SOOOO tricky and error
prone! Isn't there a simpler way?
(clarified the last paragraph)
- [16.17] But the above Matrix class is specific to
Fred! Isn't there a way to make it generic?
(rewrote)
- [16.18] Does C++ have arrays whose length can be specified at
run-time?
(changed so it uses new-style headers and the std:: syntax and reworded references to STL)
- [16.21] How do I provide reference counting with copy-on-write
semantics?
(rewrote the first paragraph for clarity thanks to Fabrice Clerc)
- [16.22] How do I provide reference counting with
copy-on-write semantics for a hierarchy of classes?
(changed so it uses new-style headers and the std:: syntax)
- [17.5] How do I change the string-length of an array of
char to prevent memory leaks even if/when someone throws an exception?
(rewrote the last half)
- [18.1] What is "const correctness"?
(changed so it uses new-style headers and the std:: syntax)
- [18.2] How is "const correctness" related to ordinary
type safety?
(changed so it uses new-style headers and the std:: syntax)
- [18.9] What is a "const member function"?
(removed a spurious ")" thanks to Stan Brown)
- [18.12] Why does the compiler allow me to change an int after
I've pointed at it with a const int*?
(changed so it uses new-style headers and the std:: syntax)
- [19.3] How do you express inheritance in C++?
(added "derived class of" to the list of synonyms)
- [19.7] How can I protect derived classes from breaking when I
change internal parts?
(renamed "subclass" to "derived class")
- [21.4] Is an array of Derived a kind-of array of Base?
(changed so it uses new-style headers and the std:: syntax and reworded references to STL)
- [21.5] Does array-of-Derived is-not-a-kind-of
array-of-Base mean arrays are bad?
(changed so it uses new-style headers and the std:: syntax and reworded references to STL)
- [22.3] What is an ABC?
(renamed "subclass" to "derived class")
- [22.4] What is a "pure virtual" member function?
(renamed "subclass" to "derived class")
- [24.3] Which should I prefer: composition or private
inheritance?
(changed so it uses new-style headers and the std:: syntax)
- [24.5] How is protected inheritance related to private
inheritance?
(renamed "subclass" to "derived class")
- [24.6] What are the access rules with private
and protected inheritance?
(renamed "subclass" to "derived class")
- [25.4] What's the difference between <xxx> and
<xxx.h> headers?
(changed <xyz.h> to <xxx.h> and misc wordsmithing thanks to Stan Brown)
- [25.5] Is the ?: operator evil since it can be used to create
unreadable code?
(changed so it uses new-style headers and the std:: syntax)
- [25.9] Are there any lint-like guidelines for C++?
(changed so it uses new-style headers and the std:: syntax)
- [25.10] Which is better: identifier names
that_look_like_this or identifier names thatLookLikeThis?
(improved the precision and added the last two paragraphs thanks to Chris Hurst)
- [25.11] Are there any other sources of coding standards?
(fixed some URLs thanks to James S. Adelman and Stan Brown)
- [27.4] How do you use inheritance in C++, and is that
different from Smalltalk?
(renamed "subclass" to "derived class")
- [27.5] What are the practical consequences of
differences in Smalltalk/C++ inheritance?
(renamed "subclass" to "derived class")
- [28.3] What's the difference between virtual data and
dynamic data?
(renamed "subclass" to "derived class")
- [28.8] Does the poor performance of reference semantics mean I
should pass-by-value?
(renamed "subclass" to "derived class")
- [31.2] How can I make a perl-like associative array in
C++?
(changed so it uses new-style headers and the std:: syntax)
- [31.4] How can I insert/access/change elements from a linked
list/hashtable/etc?
(reworded, plus changed so it uses new-style headers and the std:: syntax)
- [31.6] What's the syntax / semantics for a "function template"?
(changed so it uses new-style headers and the std:: syntax)
- [31.7] What's the syntax / semantics for a "class template"?
(changed so it uses new-style headers and the std:: syntax)
- [32.1] What is the "STL"?
(changed so it uses new-style headers and the std:: syntax)
- [32.2] Where can I get a copy of "STL"?
(added URLs for the SGI implementation and STLport thanks to Stan Brown)
- [32.3] How can I find a Fred object in an STL
container of Fred* such as std::vector<Fred*>?
(changed so it uses new-style headers and the std:: syntax)
- [33.5] Where can I get information about the C++ compiler
from {Borland, IBM, Microsoft, Semantic, Sun, etc.}?
(updated the URL for IBM VisualAge C++ thanks to Rick Alther; updated the URL for GNU C++ thanks to Martin Honnen)
- [34.1] What should be done with macros that contain if?
(added the last three paragraphs, including the link showing why we don't use do {...} while (false))
- [34.2] What should be done with macros that have multiple
lines?
(changed "if (1)..." to "if (true)..." and "do...while (0)" to "do...while (false)")
- [34.5] What are the C++ scoping rules for for loops?
(because the scoping rules for for loops are no longer "new" (thanks Stan Brown), rewote the FAQ)
- [34.8] Why is floating point so inaccurate? Why doesn't this
print 0.43?
(changed so it uses new-style headers and the std:: syntax)
- [34.12] Why can't I put a forward-declared class in a std::vector<>?
(changed so it uses new-style headers and the std:: syntax)
- [35.2] Are there any pretty-printers that reformat C++ source
code?
(added HPS Beauty)
- [35.5] Why does my DOS C++ program says "Sorry: floating
point code not linked"?
(added a cross reference and updated to new header syntax)
[ Top | Bottom | Previous section | Next section ]
[4.2] What updates were made for the 03/00 release?
[Recently created (on 3/00). Click here to go to the next FAQ in the "chain" of recent changes.]
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.3] What updates were made for the 01/00 release?
New FAQs:
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.11] 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.4] 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)
[ Top | Bottom | Previous section | Next section ]
[4.4] What updates were made for the 10/99 release?
New FAQs:
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.8] How can I provide input for my class Fred?
(added return type to main())
- [15.11] 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.2] How can I make a perl-like associative array in
C++?
(added return type to main())
- [31.6] What's the syntax / semantics for a "function template"?
(added return type to main())
- [31.7] 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)
[ Top | Bottom | Previous section | Next section ]
[4.5] What updates were made for the 07/99 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.6] What updates were made for the 06/98 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.7] 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:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.8] What updates were made for the 09/97 release?
New FAQs:
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++ 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)
[ Top | Bottom | Previous section | Next section ]
[4.9] What updates were made for the 01/97 release?
Global changes:
- Added the (much requested!) one-click download
feature. 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.
- 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:
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.8] 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)
[ Top | Bottom | Previous section | Next section ]
[4.10] What updates were made for the 11/96 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.11] What updates were made for the 10/96 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.12] What updates were made for the 09/96 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.13] What updates were made for the 08/96 release?
Global changes:
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.14] What updates were made for the 07/96 release?
Global changes:
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.15] What updates were made for the 06/96 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.16] 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.
[ Top | Bottom | Previous section | Next section ]
[4.17] What updates were made for the 04/96 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.18] What updates were made for the 03/96 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.19] What updates were made for the 09/95 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.20] What updates were made for the 06/95 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.21] What updates were made for the 04/95 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.22] What updates were made for the 03/95 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.23] What updates were made for the 01/95 release?
New FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.24] What updates were made for the 12/94 release?
New FAQs:
Changed FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.25] What updates were made for the 11/94 release?
New FAQs:
[ Top | Bottom | Previous section | Next section ]
[4.26] 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:
[ Top | Bottom | Previous section | Next section ]
[4.27] 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.
[ Top | Bottom | Previous section | Next section ]
E-mail the author
[ C++ FAQ Lite
| Table of contents
| Subject index
| About the author
| ©
| Download your own copy ]
Revised Jul 10, 2000